Re: python to exe

2010-03-12 Thread Steven D'Aprano
On Fri, 12 Mar 2010 22:26:34 -0600, John Bokma wrote:

> Gabriel Genellina  writes:
> 
>> On 13 mar, 00:26, Robin  wrote:
>>
>>> Does anyone know of a good python to stand alone exe compiler?
>>
>> http://tinyurl.com/yfcfzz4
> 
> Wow, pathetic fuck. You don't have to post you know.

Gabriel is one of the more helpful and newbie-friendly of the frequent 
posters on this newsgroup. Even if his actions were worthy of your abuse 
(and they aren't), he gets at least one Get Out Of Jail Free card for his 
long-term helpfulness.

Speaking as somebody who finds Let Me Google That For You to be tiresome 
and not at all amusing, nevertheless I support Gabriel's actions. By 
merely giving Robin the answer, Robin doesn't learn how to find out the 
answer to simple questions himself, and by rewarding his laziness, we 
make a rod for our own back.

As the old proverb goes: give a man a fish, and you feed him for a day. 
Teach him how to fish, and he has food forever.

I'm an old-fashioned kind of guy, and don't like LMGTFY because it is 
tiresome and requires Javascript. I prefer:

Google is your friend:

http://www.google.com/search?q=python+standalone+exe

Oh, and Robin, since you have apparently already tried py2exe and found 
it doesn't work on Windows 7, you should have said so from the start, 
instead of wasting everyone's time.



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


Re: python to exe

2010-03-12 Thread Chris Rebert
On Fri, Mar 12, 2010 at 8:42 PM, robin  wrote:
> On 3/12/2010 9:12 PM, Chris Rebert wrote:
>> On Fri, Mar 12, 2010 at 7:26 PM, Robin  wrote:
>>> Does anyone know of a good python to stand alone exe compiler?
>>>
>> py2exe:
>> http://www.py2exe.org/
>
> do you  of an alternate compilter it doesn't work (py2exe) on my windows 7
> box, I hate windows7 THanks Robin

Nope; py2exe is pretty much the go-to tool for this.
Try asking on their mailinglist:
https://lists.sourceforge.net/lists/listinfo/py2exe-users

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: POS Tagging

2010-03-12 Thread Hephzibah
On Mar 12, 4:33 pm, John Bokma  wrote:
> Hephzibah  writes:
> > ImportError: No module named numpy
>
> > Can someone pls. tell me what I'm supposed to do next?
>
> Install numpy would be my first guess.
>
> --
> John Bokma                                                               j3b
>
> Hacking & Hiking in Mexico -  http://johnbokma.com/http://castleamber.com/- 
> Perl & Python Development

Thanks so much

I've been able to resolve the issue.
What  I did was to run the program after downloading and installing
i. a newer version of Python -version 26
ii. pyPAML
iii.numpy
iv.matplotlib; all from www.nltk.org.

regards,
Hephzibah

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


Re: python to exe

2010-03-12 Thread John Bokma
Gabriel Genellina  writes:

> On 13 mar, 00:26, Robin  wrote:
>
>> Does anyone know of a good python to stand alone exe compiler?
>
> http://tinyurl.com/yfcfzz4

Wow, pathetic fuck. You don't have to post you know.

-- 
John Bokma   j3b

Hacking & Hiking in Mexico -  http://johnbokma.com/
http://castleamber.com/ - Perl & Python Development
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python to exe

2010-03-12 Thread Gabriel Genellina
On 13 mar, 00:26, Robin  wrote:

> Does anyone know of a good python to stand alone exe compiler?

http://tinyurl.com/yfcfzz4

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


Re: file seek is slow

2010-03-12 Thread CHEN Guang
>> Metalone wrote:
>>> I just tried the seek test with Cython.
>>> Cython fseek() : 1.059 seconds.  30% slower than 'C'
>>> Python f.seek  : 1.458 secondds. 80% slower than 'C'.
>>>
>>> It is amazing to me that Cython generates a 'C' file that is 1478
>>> lines.
>>
>> PythoidC ( http://pythoidc.googlecode.com ) generates the shortest 'C' file.
>> PythoidC is the C language like the Python, by the Python and for the Python.

>Except that it's not a language but rather a syntax converter, i.e. it 
>doesn't really add any features to the C language but rather restricts 
>Python syntax to C language features (plus a bit of header file 
>introspection, it seems, but C's preprocessor has a bit of that, too).
>Stefan

PythoidC is a familar language to Python and C programmers, I do not like
waste my time to create unfamilar things to waste users' time studying. 
In fact PythoidC removed some boring features from C language:
1. no semicolon ; at line ends
2. no braces {} , take Pythonic indent region to express code block
PythoidC restricts C syntax to Python language feature, so that 
C language bacomes friendly to Python programmers and Python IDE. 
PythoidC realized introspection not only on header files but also any C files.
The PythoidC introspection will be as good as Python introspection, 
if only the C header file wirters adds more detailed annotation. 
PythoidC is a familar and convenient C language tool for Python programmers and 
mixed programming.
plus, PythoidC is realizable only with Python, it's too far beyond C's 
preprocessor, believe it, or show us. 
CHEN Guang
Convenient C Python mixed programming --- PythoidC ( 
http://pythoidc.googlecode.com )
 -- 
http://mail.python.org/mailman/listinfo/python-list


Re: python to exe

2010-03-12 Thread Chris Rebert
On Fri, Mar 12, 2010 at 7:26 PM, Robin  wrote:
> Does anyone know of a good python to stand alone exe compiler?

py2exe:
http://www.py2exe.org/

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


python to exe

2010-03-12 Thread Robin
Does anyone know of a good python to stand alone exe compiler?

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


Re: StringChain -- a data structure for managing large sequences of chunks of bytes

2010-03-12 Thread Steven D'Aprano
On Fri, 12 Mar 2010 13:40:23 +, MRAB wrote:

>> To be taken seriously, I think you need to compare stringchain to the
>> list idiom. If your benchmarks favourably compare to that, then it
>> might be worthwhile.
>> 
> IIRC, someone did some work on making concatenation faster by delaying
> it until a certain threshold had been reached (in the string class
> implementation).

I believe you're talking about this patch:

http://bugs.python.org/issue1569040

It's never been formally rejected, but the chances of it being accepted 
are pretty low.


However, in Python 2.4 another optimization was added that makes string 
concatenation of the form:

a = a + b
a += b

much faster. This is implementation specific (Jython and IronPython don't 
have it, and almost certainly won't) and it doesn't work for (e.g.):

a = b + a

See here: 

http://mail.python.org/pipermail/python-dev/2004-August/046686.html
http://bugs.python.org/issue980695



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


Re: Python eCommerce, small webshop

2010-03-12 Thread Alexander Kapps
Sorry, Emile for the private post, one beer too much and the wrong 
button... ;-)


Emile van Sebille wrote:

> On 3/12/2010 5:02 PM Alexander Kapps said...
>> Hello everybody!
>>
>> I have to set up a small webshop for used books, CDs, DVD, and 
stuff and

>> did't find anything realy usefull on google.
>
> Have you checked the current status of Satchmo?

Sort of. I checked their site and feature list which looks 
promising. Then I searched for a forum. I have quite some objections 
 against projects who only have a google group with a reaction time 
measured in days.


But since you mentioned it, I'll have a closer look.

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


Python eCommerce, small webshop

2010-03-12 Thread Alexander Kapps

Hello everybody!

I have to set up a small webshop for used books, CDs, DVD, and stuff 
 and did't find anything realy usefull on google.


I'm pretty skilled with Python and would strongly prefer a Python 
based Shop but all I've found are in early stage, unmaintained or 
too limited.


I've looked around and found many PHP based shops (currently I'm 
playing with OpenCart but their code is so messy, I don't think this 
is going to work) and some Ruby based ones (I don't know Ruby at all)


I there really no decent, up-to-date, activily maintained and post 
beta stage Python webshop?


What I need is:

- full german support (ie. translation, shipping models, payment 
models, etc)

- secure (code, SQL, full SSL, etc)
- themable without getting into all gory details of modern HTML/CSS 
(a bit is OK)

- customizable by people with good Python and basic SQL knowledge
- finally (after being setup) usable by people without any 
programming skills at all.




Thanks for any tips.

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


Re: Python eCommerce, small webshop

2010-03-12 Thread Emile van Sebille

On 3/12/2010 5:02 PM Alexander Kapps said...

Hello everybody!

I have to set up a small webshop for used books, CDs, DVD, and stuff and
did't find anything realy usefull on google.


Have you checked the current status of Satchmo?

Emile




I'm pretty skilled with Python and would strongly prefer a Python based
Shop but all I've found are in early stage, unmaintained or too limited.

I've looked around and found many PHP based shops (currently I'm playing
with OpenCart but their code is so messy, I don't think this is going to
work) and some Ruby based ones (I don't know Ruby at all)

I there really no decent, up-to-date, activily maintained and post beta
stage Python webshop?

What I need is:

- full german support (ie. translation, shipping models, payment models,
etc)
- secure (code, SQL, full SSL, etc)
- themable without getting into all gory details of modern HTML/CSS (a
bit is OK)
- customizable by people with good Python and basic SQL knowledge
- finally (after being setup) usable by people without any programming
skills at all.



Thanks for any tips.

Regards
Alex



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


Python eCommerce, small webshop

2010-03-12 Thread Alexander Kapps

Hello everybody!

I have to set up a small webshop for used books, CDs, DVD, and stuff 
 and did't find anything realy usefull on google.


I'm pretty skilled with Python and would strongly prefer a Python 
based Shop but all I've found are in early stage, unmaintained or 
too limited.


I've looked around and found many PHP based shops (currently I'm 
playing with OpenCart but their code is so messy, I don't think this 
is going to work) and some Ruby based ones (I don't know Ruby at all)


I there really no decent, up-to-date, activily maintained and post 
beta stage Python webshop?


What I need is:

- full german support (ie. translation, shipping models, payment 
models, etc)

- secure (code, SQL, full SSL, etc)
- themable without getting into all gory details of modern HTML/CSS 
(a bit is OK)

- customizable by people with good Python and basic SQL knowledge
- finally (after being setup) usable by people without any 
programming skills at all.




Thanks for any tips.

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


Re: POS Tagging

2010-03-12 Thread John Bokma
Hephzibah  writes:

> ImportError: No module named numpy
>
> Can someone pls. tell me what I'm supposed to do next?

Install numpy would be my first guess.

-- 
John Bokma   j3b

Hacking & Hiking in Mexico -  http://johnbokma.com/
http://castleamber.com/ - Perl & Python Development
-- 
http://mail.python.org/mailman/listinfo/python-list


POS Tagging

2010-03-12 Thread Hephzibah
I just started working on POS tagging with these codes:

import nltk
text = nltk.word_tokenize("And now for something completely
different")
#print text
print nltk.pos_tag(text)

Python prompted me to download a resource with these codes:

Resource 'taggers/maxent_treebank_pos_tagger/english.pickle' not
found.  Please use the NLTK Downloader to obtain the resource:

I download the resources available using nltk.download(). But  I
couldn't run POS tagger. Python gave my the following message:

Traceback (most recent call last):
  File "C:/Python25/tag practices.py", line 5, in 
print nltk.pos_tag(text)
  File "C:\Python25\lib\site-packages\nltk\tag\__init__.py", line 62,
in pos_tag
tagger = nltk.data.load(_POS_TAGGER)
  File "C:\Python25\lib\site-packages\nltk\data.py", line 492, in load
resource_val = pickle.load(_open(resource_url))
  File "C:\Python25\lib\site-packages\nltk\classify\maxent.py", line
57, in 
import numpy
ImportError: No module named numpy

Can someone pls. tell me what I'm supposed to do next?

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


Re: Unicode characters in btye-strings

2010-03-12 Thread Martin v. Loewis
Michael Rudolf wrote:
> Am 12.03.2010 21:56, schrieb Martin v. Loewis:
>> (*) If a source encoding was given, the source is actually recoded to
>> UTF-8, parsed, and then re-encoded back into the original encoding.
> 
> Why is that?

Why is what? That string literals get reencoded into the source encoding?

> So "unicode"-strings (as in u"string") are not really 
> unicode-, but utf8-strings?

No. String literals, in 2.x, are not written with u"", and are stored in
the source encoding. Above procedure applies to regular strings (see
where the "*" goes in my original article).

> Need citation plz.

You really want a link to the source code implementing that?

Regards,
Martin
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Unicode characters in btye-strings

2010-03-12 Thread John Bokma
Michael Rudolf  writes:

> Am 12.03.2010 21:56, schrieb Martin v. Loewis:
>> (*) If a source encoding was given, the source is actually recoded to
>> UTF-8, parsed, and then re-encoded back into the original encoding.
>
> Why is that? So "unicode"-strings (as in u"string") are not really
> unicode-, but utf8-strings?

utf8 is a Unicode *encoding*.

-- 
John Bokma   j3b

Hacking & Hiking in Mexico -  http://johnbokma.com/
http://castleamber.com/ - Perl & Python Development
-- 
http://mail.python.org/mailman/listinfo/python-list


converting datetime with tzinfo to unix timestamp

2010-03-12 Thread Michael Torrie
On Python 2.5 here.

I've searched and searched but I can't find any way to convert a
datetime object that includes a timezone (tzinfo) to a unix timestamp.
Folks on the net say to simply use the timetuple() method of the object
and feed that to time.mktime().  But that just doesn't seem to work for
me.  At least if my understanding that the unix timestamp is always UTC.

I'm using the pytz module to create a datetime object of a certain
timezone.  For example:


import pytz
import datetime
import time

mountain = pytz.timezone("US/Mountain") # MST or MDT depending on date
eastern = pytz.timezone("US/Eastern")   # EST or EDT depending on date

date1 = mountain.localize(datetime.datetime(2010, 3, 12, 9, 0))
date2 = eastern.localize(datetime.datetime(2010, 3, 12, 9, 0))

Now if I examine the two objects, I get:
>>> print date1
2010-03-12 09:00:00-07:00

>>> print date2
2010-03-12 09:00:00-05:00

However the standard time.mktime(date2.timetuple()) thing gives me a
timestamp, but it's in my local timezone and gives me the same answer
for both dates!

Can anyone point me in the right direction?

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


Re: Unicode characters in btye-strings

2010-03-12 Thread Michael Rudolf

Am 12.03.2010 21:56, schrieb Martin v. Loewis:

(*) If a source encoding was given, the source is actually recoded to
UTF-8, parsed, and then re-encoded back into the original encoding.


Why is that? So "unicode"-strings (as in u"string") are not really 
unicode-, but utf8-strings?


Need citation plz.

Thx,
Michael
--
http://mail.python.org/mailman/listinfo/python-list


Re: Unicode characters in btye-strings

2010-03-12 Thread Martin v. Loewis
>> Can somebody explain what happens when I put non-ASCII characters into a
>> non-unicode string? My guess is that the result will depend on the
>> current encoding of my terminal.
> 
> Exactly right.

To elaborate on the "what happens" part: the string that gets entered is
typically passed as a byte sequence, from the terminal (application) to
the OS kernel, from the OS kernel to Python's stdin, and from there to
the parser. Python recognizes the string delimiters, but (practically)
leaves the bytes between the delimiters as-is (*), creating a byte
string object with the very same bytes.

The more interesting question is what happens when you do

py> s = u"éâÄ"

Here, Python needs to decode the bytes, according to some encoding.
Usually, it would want to use the source encoding (as given through
-*- Emacs -*- markers), but there are none. Various Python versions then
try different things; what they should do is to determine the terminal
encoding, and decode the bytes according to that one.

Regards,
Martin

(*) If a source encoding was given, the source is actually recoded to
UTF-8, parsed, and then re-encoded back into the original encoding.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Anything like "Effective Java" for Python?

2010-03-12 Thread John Bokma
Gabriel Rossetti  writes:

> kj wrote:
>>
>> Subject line pretty much says it all: is there a book like "Effective
>> Java" for Python.  I.e. a book that assumes that readers are
>> experienced programmers that already know the basics of the language,
>> and want to focus on more advanced programming issues?
>
> Effective Java is a good book, it is not like most people responding
> to this topic a "how to program in Java"

I had more the feeling that these responses were more of the "Look, you
actually need a book to learn how to program effectively in Java
*snigger*" fanboism.

> book but a "I know how to program in Python, but I want it to run fast
> and use a minimal amount of memory".
> I would have liked to have such a book for Python when I was past the
> language learning stage.

High Performance Python by Anthony Lewis (Author), et al. (*snigger*!)

might be such a book but we have to wait a few more months:
Publisher: O'Reilly Media; 1 edition (September 15, 2010)
(It has been on my wish list for several months)

To the OP: right now, Dive into Python is clearly written with people
who have experience with programming in mind. I've both the Python 2 and
Python 3 version (books). You can download a version of each for free:

http://www.google.com/search?q=dive%20into%20python

-- 
John Bokma   j3b

Hacking & Hiking in Mexico -  http://johnbokma.com/
http://castleamber.com/ - Perl & Python Development
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: file seek is slow

2010-03-12 Thread Metalone
I almost wrote a long reply to all this.
In the end it boils down to being concerned about how much overhead
there is to calling a 'C' function.
I assumed that file.seek() simply delegated to fseek() and thus was
one way to test this overhead.
However, I now think that it must be doing more and may not be a
reasonable comparison.

I have used the profiler about as much as I can to find where my
program is slow, and it appears to me that
the overhead to calling 'C' functions is now my biggest problem.
I have been using Ctypes, which has been a great tool so far.
I just discovered Cython and this looks like it may help me.
I had not heard of pythoid, so I will check it out.

I did not mean to offend anybody in Cython community.
It just seemed funny to me that 21 lines of Python became 1478 lines
of 'C'.
I wasn't really expecting any response to this.
I don't know enough about this to really assume anything.

Stephan,
I just tested 1e7 loops.
'C': 8.133 seconds
Cython: 10.812 seconds

I can't figure out what Cython is using for CFLAGS, so this could be
important.

I used While instead of xrange, because I thought it would be faster
in Cython.
They had roughly the same execution speed.

Thanks all for the suggestions.
I think I will just consider this thread closed.


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


Re: NoSQL Movement?

2010-03-12 Thread Paul Rubin
"D'Arcy J.M. Cain"  writes:
> Just curious, what database were you using that wouldn't keep up with
> you?  I use PostgreSQL and would never consider going back to flat
> files.  

Try making a file with a billion or so names and addresses, then
compare the speed of inserting that many rows into a postgres table
against the speed of copying the file.

> The only thing I can think of that might make flat files faster is
> that flat files are buffered whereas PG guarantees that your
> information is written to disk before returning 

Don't forget all the shadow page operations and the index operations,
and that a lot of these operations require reading as well as writing
remote parts of the disk, so buffering doesn't help avoid every disk
seek.

Generally when faced with this sort of problem I find it worthwhile to
ask myself whether the mainframe programmers of the 1960's-70's had to
deal with the same thing, e.g. when sending out millions of phone bills,
or processing credit card transactions (TPF), then ask myself how they
did it.  Their computers had very little memory or disk space by today's
standards, so their main bulk storage medium was mag tape.  A heck of a
lot of these data processing problems can be recast in terms of sorting
large files on tape, rather than updating database one record at a time
on disk or in memory.  And that is still what (e.g.) large search
clusters spend a lot of their time doing (look up the term "pennysort"
for more info).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python, Reportlabs, Pil and Windows 7 (64bit)

2010-03-12 Thread Martin v. Löwis
> Not sure if this is a bug

I think it is. It seems that the cross-build support in msvc9compiler
has been tested only in a build tree of Python (where there is no Libs
directory).

For released copies of Python, I could change that to distribute the
AMD64 pythonXY.lib in libs/amd64. [FWIW, I'm still puzzled why I ship
the import libraries of all the pyd files as well - I can't see a reason
other than tradition]. Then, distutils should change to look it up there.

Regards,
Martin
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Need advice on starting a Python group

2010-03-12 Thread Kurt Smith
On Thu, Mar 11, 2010 at 8:57 AM, gb345  wrote:
>
>
>
> I'm hoping to get advice from anyone with prior experience setting
> up a Python group.
>
> A friend of mine and I have been trying to start a
> scientific-programming-oriented Python group in our school (of
> medecine and bio research), with not much success.
>
> The main problem is attendance.  Even though a *ton* of people have
> told us that it's a great idea, that they're *very* interested,
> and have asked to be added to our mailing list, the attendance to
> our first few meeting has never been more than 5, including my
> friend and I.  Last time just he and I showed up.
>
> The second problem is getting content.  The format we'd envisioned
> for this group was centered around code review (though not limited
> to it).  The idea was that at every meeting a different member
> would show some code.  This could be for any of a number of reasons,
> such as, for example, 1) illustrate a cool module or technique; 2)
> present a scientific research problem and how they used Python to
> solve it, or get help solving it; 3) get general feedback (e.g. on
> code clarity, software usability, module architecture, etc.).  But
> in principle just about anything is OK: e.g. a talk on favorite
> Python resources, or a comparison of Python with some other language,
> or an overview of Python gotchas would all be fair game.
>
> Also, we stressed that the talks were not expected to be polished:
> no need for PowerPoint slides, etc.  Just project any old code onto
> the screen, and talk about it, or scribble stuff on the chalkboard.
>
> Still, we have a hard time finding volunteers.
>
> And even when we've had volunteers, hardly anyone shows up!
>
> Any suggestions would be appreciated.
>
> GB
>
> P.S.  There's a Python Meetup we could go to, but it does not fit
> the bill for us: it doesn't meet often enough, it's sort of out of
> the way, and has practically no one doing scientific programming.
> --
> http://mail.python.org/mailman/listinfo/python-list
>

There's a general Scientific Computing interest group that gets
together here at the University of Wisconsin-Madison, and it has a
significant Python component & focus.  They put on a Python bootcamp
this January that was a huge success.

http://hackerwithin.org/cgi-bin/hackerwithin.fcgi/wiki

They have bi-weekly meetings, sometimes it's of the 'come and share on
X topic,' although many times its 'local guest speaker is coming to
speak about Y'.  My impression is that the latter meetings grabbed a
number of people around campus -- 'hey, I need to do Y, I'll see what
the speaker has to say,' and then they started coming for the
show-and-tell meetings.  My recommendation would be to provide
something of value every meeting, the more specific the better.
'Python' in this regard is a bit open ended.  You'd likely get more
involvement if you had meetings that focused on, e.g., parallel
computing (and have examples in python (mpi4py), and have someone come
and talk about MPI or something), or scientific data formats (with
examples of pyhdf5 or pytables...), or you could advertise a tutorial
on some scipy & numpy features and their advantages over using
matlab/octave/idl.

It's more work than show-and-tell meetings, but look at it as priming the pump.

There is much interest around here re: Python in science, but many
have only heard about it, some have dabbled but put it on the shelf,
others couldn't get it to work (they're scientists and used to
prepackaged software that works out of the box -- if it doesn't, it's
somebody else's problem), many others can't justify the time it would
take to learn it when they already have something else working.  Until
something with value comes along (like your meeting with specific
topics) to change their minds, an open-ended meeting won't appeal much
to them.

Just some thoughts, and an example of what's worked here.  Personally
I tend to make it to the meetings with a specific topic, and end up
skipping the ones that are more open-ended.

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


Re: question regarding wxSlider

2010-03-12 Thread Philip Semanchuk

On Mar 12, 2010, at 1:56 PM, Ugo Cupcic wrote:


Hi all,

I have a question regarding wxSlider. I'm developing a wxwidget python
interface for a robotic hand. The sliders send the target values to  
the

joints.

I'd like to display the current position of the joint on the slider. I
wanted to use wxSlider.SetTick(myposition) but I couldn't get  
SetTick to

display anything.

Anyone has an idea ? I attached a dummy code to the message to  
illustrate.



Hi Ugo,
I don't mean to chase you away, but there is a dedicated wxPython  
mailing list where you obviously have a much better chance of getting  
an answer.


http://www.wxpython.org/maillist.php

Developing a robotic hand sounds like fun!

Cheers
Philip




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


Re: execute bash builtins in python

2010-03-12 Thread alex goretoy
Steve thank you. The problem is that you can only run commands from Popen or
os.system and stuff. You cant run bash shell builtin commands for some
reason.

I was able to get this to work. What I did is call this:

Popen(["bash -c 'source
$HOME/.bashrc;alias'"],shell=True,stdout=PIPE).stdout.read()

and make sure you don't have a line like this in your .bashrc:
[ -z "$PS1" ] && return

Another approach I came up with was to set aliases and functions as a
environment variable and access them with os.environ.

this is how I'm doing it.

export ALIASES=`alias|awk '{print $2}'|cut -d = -f 1|xargs`
export FUNCTIONS=`declare -F|awk '{print $3}'|xargs`

use this at the end or the .bashrc and then you can access defined aliases
and functions inside python with environ

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


question regarding wxSlider

2010-03-12 Thread Ugo Cupcic
Hi all,

I have a question regarding wxSlider. I'm developing a wxwidget python
interface for a robotic hand. The sliders send the target values to the
joints.

I'd like to display the current position of the joint on the slider. I
wanted to use wxSlider.SetTick(myposition) but I couldn't get SetTick to
display anything.

Anyone has an idea ? I attached a dummy code to the message to illustrate.

Cheers,

Ugo

-- 
  Ugo Cupcic
http://www.genugo.com/ugocupcic
   _
  ' v '
/  \
 m m
#!/usr/bin/python
import sys
sys.path.append("python_hand_library/")
from shadowhand import ShadowHand


# import the wxPython GUI package
import wx


# Create a new frame class, derived from the wxPython Frame.
class MyFrame(wx.Frame):

def __init__(self, parent, id, title):
# First, call the base class' __init__ method to create the frame
wx.Frame.__init__(self, parent, id, title)

#shadow arm -> TODO : use dialog window to set ssh / not ssh  
self.myShadowHand = ShadowHand(0)

# Add a panel and some controls to display the size and position
panel = wx.Panel(self, -1)

#display a slider for each joints
self.joints = []
self.labels = []
self.sliders = []
self.slidervalues = []
for joint in self.myShadowHand.handJoints:
self.slidervalues.append(self.myShadowHand.valueof(joint.name))
self.joints.append(joint)
self.labels.append(wx.StaticText(panel, -1, joint.name))
self.sliders.append(wx.Slider(panel, -1, value = self.myShadowHand.valueof(joint.name), minValue = joint.min, 
 maxValue = joint.max, size=(25,200), style = wx.VERTICAL | wx.SL_LABELS | wx.SL_AUTOTICKS  ))

self.panel = panel


# initialize the positions + sendupdate only when relevant
self.oldPositions = []
for joint in self.joints:
self.oldPositions.append(self.myShadowHand.valueof(joint.name))

# Use some sizers for layout of the widgets
sizer = wx.FlexGridSizer(vgap=5, hgap=20)
subsizers = []

index = 0
for label in self.labels:
# draw the stuff
subsizerTmp = wx.FlexGridSizer(rows=2, cols=1, vgap = 10)
subsizerTmp.Add(self.sliders[index])
subsizerTmp.Add(label)
subsizers.append(subsizerTmp)
index += 1

for subsizer in subsizers:
sizer.Add(subsizer)

self.timer = wx.Timer(self)  


# bind the slider event
self.Bind(wx.EVT_SLIDER, self.sliderUpdate)
self.Bind(wx.EVT_TIMER, self.update, self.timer)
  
self.timer.Start(250)

border = wx.BoxSizer()
border.Add(sizer, 0, wx.ALL, 15)
panel.SetSizerAndFit(border)
self.Fit()

def sliderUpdate(self, event):
index = 0 
for slider in self.sliders:
#value_tmp = slider.GetValue()
#if self.oldPositions[index] != value_tmp:
#self.myShadowHand.sendupdate(self.joints[index].name, value_tmp)
self.slidervalues[index] = slider.GetValue()
#index += 1
#self.myShadowHand.resend_targets(self.slidervalues)

def update(self, event):
self.myShadowHand.resend_targets(self.slidervalues)

# Every wxWidgets application must have a class derived from wx.App
class MyApp(wx.App):

# wxWindows calls this method to initialize the application
def OnInit(self):

# Create an instance of our customized Frame class
frame = MyFrame(None, -1, "Joint Sliders")
frame.Show(True)

# Tell wxWindows that this is our main window
self.SetTopWindow(frame)

# Return a success flag
return True

app = MyApp(0) # Create an instance of the application class
app.MainLoop() # Tell it to start processing events
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Need advice on starting a Python group

2010-03-12 Thread CM
On Mar 11, 9:57 am, gb345  wrote:
> I'm hoping to get advice from anyone with prior experience setting
> up a Python group.
>
> A friend of mine and I have been trying to start a
> scientific-programming-oriented Python group in our school (of
> medecine and bio research), with not much success.
>
> The main problem is attendance.  Even though a *ton* of people have
> told us that it's a great idea, that they're *very* interested,
> and have asked to be added to our mailing list, the attendance to
> our first few meeting has never been more than 5, including my
> friend and I.  Last time just he and I showed up.
>
> The second problem is getting content.  The format we'd envisioned
> for this group was centered around code review (though not limited
> to it).  The idea was that at every meeting a different member
> would show some code.  This could be for any of a number of reasons,
> such as, for example, 1) illustrate a cool module or technique; 2)
> present a scientific research problem and how they used Python to
> solve it, or get help solving it; 3) get general feedback (e.g. on
> code clarity, software usability, module architecture, etc.).  But
> in principle just about anything is OK: e.g. a talk on favorite
> Python resources, or a comparison of Python with some other language,
> or an overview of Python gotchas would all be fair game.
>
> Also, we stressed that the talks were not expected to be polished:
> no need for PowerPoint slides, etc.  Just project any old code onto
> the screen, and talk about it, or scribble stuff on the chalkboard.
>
> Still, we have a hard time finding volunteers.
>
> And even when we've had volunteers, hardly anyone shows up!

Do you advertise each time and describe what the topic will be for
that meeting and why the attendees should care?  That might make a
difference.  I.e., there's a big difference between:

a) The Thursday afternoon Python for scientific applications is
meeting, and I should remember that this week amidst all the other
stuff I have going on.

and

b) Wow, this Thursday there will be an hour workshop on how to create
publication quality graphs (somewhat) easily in Python using ready-
made tools...and there will be pizza!

Also, giving it a cool acronymic name doesn't hurt.  :D

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


Re: Threading, Queue for a function so it only runs once at a time.

2010-03-12 Thread John P.
On Fri, 12 Mar 2010 16:49:04 +, "John P." 
wrote:
> On Fri, 12 Mar 2010 11:22:04 -0500, "D'Arcy J.M. Cain" 
> wrote:
>> On Fri, 12 Mar 2010 15:56:12 +
>> "John P."  wrote:
>>> Sorry but its not really an option for me with PostgreSQL. Thanks
> anyway.
>> 
>> Why?  It's your best option.  Any other solutions that you can't use
>> before people give you more suggestions?
> 
> Chill. I didn't ask for an alternative to my database, it could be
writing
> in a file as well. What I need is some kind of queue to my function so
it
> doesnt crack up running 20 times at the same time. I'm working on a
remote
> server which I share with some friends, meaning I can't install whatever
I
> want to. 
> The problem seems to be that my threads are making MySQL queries at the
> same time before it can fetch the data just requested. Also I said
thanks
> for his effort trying to help and kept a nice tone, shouldn't that be
> enough? 
> 
> /John

Don't worry guys, I found a solution. My problem was caused because I used
the same mysql connection for all the treads, now its working perfectly,
with mysql. 

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


Re: file seek is slow

2010-03-12 Thread Antoine Pitrou
Le Tue, 09 Mar 2010 15:56:47 -0800, Metalone a écrit :
> for i in xrange(100):
>f1.seek(0)

This is quite a stupid benchmark to write, since repeatedly seeking to 0 
is a no-op. I haven't re-read the file object code recently, but chances 
are that the Python file object has its own bookkeeping which adds a bit 
of execution time.

But I would suggest measuring the performance of *actual* seeks to 
different file offsets, before handwaving about the supposed "slowness" 
of file seeks in Python.

Regards

Antoine.

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


Re: Threading, Queue for a function so it only runs once at a time.

2010-03-12 Thread John P.
On Fri, 12 Mar 2010 11:22:04 -0500, "D'Arcy J.M. Cain" 
wrote:
> On Fri, 12 Mar 2010 15:56:12 +
> "John P."  wrote:
>> Sorry but its not really an option for me with PostgreSQL. Thanks
anyway.
> 
> Why?  It's your best option.  Any other solutions that you can't use
> before people give you more suggestions?

Chill. I didn't ask for an alternative to my database, it could be writing
in a file as well. What I need is some kind of queue to my function so it
doesnt crack up running 20 times at the same time. I'm working on a remote
server which I share with some friends, meaning I can't install whatever I
want to. 
The problem seems to be that my threads are making MySQL queries at the
same time before it can fetch the data just requested. Also I said thanks
for his effort trying to help and kept a nice tone, shouldn't that be
enough? 

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


Re: Asynchronous HTTP client

2010-03-12 Thread Antoine Pitrou
Le Sun, 07 Mar 2010 22:40:36 +0800, pingooo a écrit :
> I'm writing an open source python client for a web service. The client
> may be used in all kinds of environments - Linux, Mac OS X, Windows, web
> hosting, etc by others. It is not impossible to have twisted as a
> dependency, but that makes deployment a larger job than simply uploading
> a Python file.

If it can be used by non-Python users, you will have to package it using 
py2exe or py2app anyway, in which case Twisted will be bundled 
automatically and the size overhead won't be very large.


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


Re: Visual Python programming and decompilers?

2010-03-12 Thread Tim Wintle
On Thu, 2010-03-11 at 20:38 +0200, Ludolph wrote:
> 
> I decided I can use byteplay3 http://pypi.python.org/pypi/byteplay/ to
> disassemble the code to workable objects, It even allows me to rebuild
> the objects to bytecode. So if I define patterns on how python
> interrupts the source code to bytecode I can visually represent this
> and also so convert my visual representations back to bytecode.

Assuming you're on 2.6 or later, I'd suggest working with the ast module
instead:
http://docs.python.org/library/ast.html



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


Help Troubleshooting

2010-03-12 Thread Victor Subervi
Hi;
I'm running Pexpect (no discussion list) with the following code:

#! /usr/bin/python
import pexpect

def runVpopmail(whatdo, acct, domain, newpw, oldpw=''):
  if whatdo == 'vadduser':
child = pexpect.spawn('/home/vpopmail/bin/%s %...@%s %s' % (whatdo, acct,
domain, newpw))
  elif whatdo == 'vchangepw':
child = pexpect.spawn('/home/vpopmail/bin/%s' % (whatdo))
child.expect('Please enter the email address: ')
child.sendline('%...@%s' % (acct, domain))
child.expect('Enter old password: ')
child.sendline(oldpw)
child.expect('Please enter password for %...@%s: ' % (acct, domain))
child.sendline(newpw)
child.expect('enter password again: ')
child.sendline(newpw)
  return child

No matter whether I try to add a user or edit a password, the fn seems to
return that everything is good, but nothing ever happens. When I place a
return of the child value and run it with whatdo==vadduser I get the
following output:

version: 2.3 ($Revision: 399 $) command: /home/vpopmail/bin/vadduser args:
['/home/vpopmail/bin/vadduser', 'te...@globalsolutionsgroup.vi', 'qqq']
searcher: None buffer (last 100 chars): before (last 100 chars): None after:
None match: None match_index: None exitstatus: None flag_eof: False pid:
1518 child_fd: 3 closed: False timeout: 30 delimiter: pexpect.EOF logfile:
None logfile_read: None logfile_send: None maxread: 2000 ignorecase: False
searchwindowsize: None delaybeforesend: 0.05 delayafterclose: 0.1
delayafterterminate: 0.

I don't know what this means. Any ideas on how to troubleshoot this?
TIA,
beno
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Threading, Queue for a function so it only runs once at a time.

2010-03-12 Thread D'Arcy J.M. Cain
On Fri, 12 Mar 2010 15:56:12 +
"John P."  wrote:
> Sorry but its not really an option for me with PostgreSQL. Thanks anyway.

Why?  It's your best option.  Any other solutions that you can't use
before people give you more suggestions?

-- 
D'Arcy J.M. Cain  |  Democracy is three wolves
http://www.druid.net/darcy/|  and a sheep voting on
+1 416 425 1212 (DoD#0082)(eNTP)   |  what's for dinner.
-- 
http://mail.python.org/mailman/listinfo/python-list


RE: Visual Python programming and decompilers?

2010-03-12 Thread Billy Earney
Ludolph,

This reminds me of the orange project which is developed in python.
http://www.ailab.si/orange/
It is actually for data mining, but many of the concepts could be used for a
more general programming structure.

Billy

-Original Message-
From: python-list-bounces+billy.earney=gmail@python.org
[mailto:python-list-bounces+billy.earney=gmail@python.org] On Behalf Of
Ludolph
Sent: Thursday, March 11, 2010 12:39 PM
To: python-list@python.org
Subject: Visual Python programming and decompilers?

Hi Guys

At work I have been exposed to a Agile Platform called OutSystems. It
allows you to visually program your web applications
http://i.imgur.com/r2F0i.png and I find the idea very intriguing.

So I have started to play around with the idea on how will I be able
to visually represent Python code as in the above image and then allow
the programmer to change some of the flow/code/logic visually and then
get it back as python source code. I don't know if this have been
tried before and after some googling I can't find anything like this,
so maybe I'm just lacking basic googling skills or a python solution
like the above does not exist yet.

If anybody knows of such solution please let me know, so that I don't
spend a lot of time recreating the wheel. Otherwise help me out on the
following problem:

I decided I can use byteplay3 http://pypi.python.org/pypi/byteplay/ to
disassemble the code to workable objects, It even allows me to rebuild
the objects to bytecode. So if I define patterns on how python
interrupts the source code to bytecode I can visually represent this
and also so convert my visual representations back to bytecode.

The only problem I have at the moment is how will I get this bytecode
back to python source code. I have googled for python decompiler but
only found old projects like unpyc, decompyle and some online
services. I would like to know if anybody know of a well maintained or
at least recent module that can help me accomplish the above
mentioned, because I'm hoping I can implement this in Python 3.1.

So any input or suggestion would be greatly appreciated.

Kind Regards,

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

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


Re: python module/utility equivalent to 'time' (linux) and/or 'ntimer'(Windows)

2010-03-12 Thread Godson Gera
Take a look at hotshot module of python
http://docs.python.org/library/hotshot.html

On Fri, Mar 12, 2010 at 7:26 PM, hiral  wrote:

> Hi,
>
> Is there any python module/utility available which would report the
> time same as 'time' command in linux and/or report time same as
> 'ntimer' utility in Windows.
>
> Thank you.
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Thanks & Regards,
Godson Gera
http://godson.in
http://www.clickindia.com/detail.php?id=493636
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Anything like "Effective Java" for Python?

2010-03-12 Thread Gabriel Rossetti

kj wrote:


Subject line pretty much says it all: is there a book like "Effective
Java" for Python.  I.e. a book that assumes that readers are
experienced programmers that already know the basics of the language,
and want to focus on more advanced programming issues?

~K
  


Effective Java is a good book, it is not like most people responding to 
this topic a "how to program in Java"
book but a "I know how to program in Python, but I want it to run fast 
and use a minimal amount of memory".
I would have liked to have such a book for Python when I was past the 
language learning stage.


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


Re: Threading, Queue for a function so it only runs once at a time.

2010-03-12 Thread John P.
Sorry but its not really an option for me with PostgreSQL. Thanks anyway.

I wonder if there is a simple way of just queueing the run of a function
make it only run once at a time but by multiply threads? :)

On Fri, 12 Mar 2010 00:54:57 -0800, Jonathan Gardner
 wrote:
> For lots of transactions running at once, MySQL is a terrible choice.
> Give PostgreSQL a try. It does a much better job with that kind of
> load.
> 
> On Thu, Mar 11, 2010 at 11:11 PM, John P. 
> wrote:
>> Hi,
>>
>> Im programming a simple webcrawler with threading for the fun of it,
>> which
>> is inserting the data fetch into a mysql database, but after
continuously
>> cause my mysql server to produce error during database queries (i
assume
>> its cause because of the many execution at the same time.) the scipt
>> produces errors.
>>
>> I figured out i need some kind of queue for the function i use to
insert
>> into the database, to make sure its only called once at a time.
>>
>> I have looked at the Queue module but its for more complicated than my
>> current python skills can cope with. :)
>>
>> Would somebody please help me out here?
>>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: inspect.stack() and frame

2010-03-12 Thread MRAB

Félix-Antoine Fortin wrote:

Thanks Gabriel, you resumed quite well what I did discovered after my
second post
by playing with the garbage collector module.

(The garbage collector will,  
eventually, break the cycle and free those objects, but not very soon).


I'm not very familiar with the Python garbage collector, so you may
excuse my
simple question, but how can it break the cycle? I guess the object
will be
freed at least when the program ends, but could it be before that? Is
there a
mechanisme in the garbage collector to detect circular references?


In CPython objects are reference-counted, which allows an object to be
collected as soon as there are no references to it.

However, this won't take care of circular references, so a secondary
garbage collector was introduced which occasionally looks for
inaccessible objects (garbage) using (probably) mark-and-sweep.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python, Reportlabs, Pil and Windows 7 (64bit)

2010-03-12 Thread Robin Becker

On 12/03/2010 11:40, Robin Becker wrote:



I assume I can get those from a working Python amd64 install and stuff
on one of the compiler paths somehow.



Not sure if this is a bug; I dug around a bit and find that because of the cross 
compilation distutils is supposed to add an extra library path with the name 
PCbuild\AMD64 when doing x86-->amd64 cross builds.


I tried copying the 2.6.4 amd64 libs/dlls etc etc into c:\python26\PCbuild\AMD64 
and reran my cross build


c:\python26\python setup.py build --plat-name=win-amd64

however, that still gives linker import errors.

Looked in the output I see this


C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\x86_amd64\link.exe /DLL 
/nologo /INCREMENTAL:NO /LIBPATH:C:\python26
\libs /LIBPATH:C:\python26\PCbuild\amd64 /EXPORT:init_rl_accel 
build\temp.win-amd64-2.6\Release\_rl_accel.obj /OUT:build
\lib.win-amd64-2.6\_rl_accel.pyd 
/IMPLIB:build\temp.win-amd64-2.6\Release\_rl_accel.lib 
/MANIFESTFILE:build\temp.win-amd
64-2.6\Release\_rl_accel.pyd.manifest
   Creating library build\temp.win-amd64-2.6\Release\_rl_accel.lib and object 
build\temp.win-amd64-2.6\Release\_rl_accel
.exp
_rl_accel.obj : error LNK2019: unresolved external symbol __imp_PyNumber_Int 
referenced in function _parseSequenceInt
_rl_accel.obj : error LNK2019: unresolved external symbol 
__imp_PySequence_GetItem referenced in function _parseSequence



that looks wrong because I'm using 32 bit python to do the build and

/LIBPATH:C:\python26\libs /LIBPATH:C:\python26\PCbuild\amd64

means that the 32 bit libraries are first. Running the linker command by itself 
(without the 32bit libs in the command) works fine ie



C:\ux\PydBuilder\rl_addons\rl_accel>"C:\Program Files\Microsoft Visual Studio 
9.0\VC\BIN\x86_amd64\link.exe" /DLL /nolog
o /INCREMENTAL:NO /LIBPATH:C:\python26\PCbuild\amd64 /EXPORT:init_rl_accel 
build\temp.win-amd64-2.6\Release\_rl_accel.ob
j /OUT:build\lib.win-amd64-2.6\_rl_accel.pyd 
/IMPLIB:build\temp.win-amd64-2.6\Release\_rl_accel.lib /MANIFESTFILE:build\
temp.win-amd64-2.6\Release\_rl_accel.pyd.manifest
   Creating library build\temp.win-amd64-2.6\Release\_rl_accel.lib and object 
build\temp.win-amd64-2.6\Release\_rl_accel
.exp


seems to work fine and produce a pyd in build\lib.win-amd64-2.6
--
Robin Becker
--
http://mail.python.org/mailman/listinfo/python-list


Re: Unicode characters in btye-strings

2010-03-12 Thread Robert Kern

On 2010-03-12 06:35 AM, Steven D'Aprano wrote:

I know this is wrong, but I'm not sure just how wrong it is, or why.
Using Python 2.x:


s = "éâÄ"
print s

éâÄ

len(s)

6

list(s)

['\xc3', '\xa9', '\xc3', '\xa2', '\xc3', '\x84']

Can somebody explain what happens when I put non-ASCII characters into a
non-unicode string? My guess is that the result will depend on the
current encoding of my terminal.


Exactly right.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco

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


Exiting gracefully from ThreadingTCPServer

2010-03-12 Thread Pete Emerson
I'm trying to get threading going for the first time in python, and
I'm trying to modify code I found so that I can have the server close
the TCP connections and exit gracefully. Two problems:

1) While the KeyboardInterrupt works, if I make more than 0 curls to
the server and then quit, I can't run it again right away and get
this:
socket.error: [Errno 48] Address already in use

Not all of my connections are closing properly. How do I fix this?

2) curling localhost:8080/quit does show the "Quitting" output that I
expect, but doesn't quit the server until I manually control-c it.

I think that I need *all* threads to close and not just the current
one, so I'm not quite sure how to proceed. Pointers in the right
direction are appreciated. And if there's a "better" way to do this
threading httpd server (subjective, I realize), please let me know!
Thanks.

Pete

#
#!/usr/bin/env python

import SocketServer
import SimpleHTTPServer

PORT = 8080
done = False
class CustomHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def do_GET(self):
global done
if self.path=='/quit':
self.send_response(200)
self.send_header('Content-type','text/html')
self.end_headers()
self.wfile.write('Quitting')
done = True
return self
else:
self.send_response(200)
self.send_header('Content-type','text/html')
self.end_headers()
self.wfile.write('Unknown')
return self


if __name__ == "__main__":
httpd = SocketServer.ThreadingTCPServer(('localhost',
PORT),CustomHandler)
try:
while not done:
print "done: ", done
httpd.handle_request()
except KeyboardInterrupt:
print "Server is done."
httpd.server_close()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: to create variable from dict

2010-03-12 Thread Jean-Michel Pichavant

Luis M. González wrote:

On Mar 12, 10:59 am, hiral  wrote:
  

Hi,

Is there any way to create variables which name matches with dict key?

For example:
dict1 = {"abc":'1", "def":"2"}

Now I am looking to have variable name abc and it's value be '1' etc.

Pl. suggest.

Thank you.



Check out this thread (very recent):
http://groups.google.com/group/comp.lang.python/browse_thread/thread/bb1797ffb6fc3bd7/25fe94103c7a231f?lnk=gst&q=luis+variables#25fe94103c7a231f

Short answer: you can update globals() with a dictionary, as follows:

globals().update( dict1 )

Then you'll have each key-value pair as variables in the global
namespace.
The question is: should you do it?

Luis
  

The answer is known: no, he should not do it :o)

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


Re: to create variable from dict

2010-03-12 Thread Luis M . González
On Mar 12, 10:59 am, hiral  wrote:
> Hi,
>
> Is there any way to create variables which name matches with dict key?
>
> For example:
> dict1 = {"abc":'1", "def":"2"}
>
> Now I am looking to have variable name abc and it's value be '1' etc.
>
> Pl. suggest.
>
> Thank you.

Check out this thread (very recent):
http://groups.google.com/group/comp.lang.python/browse_thread/thread/bb1797ffb6fc3bd7/25fe94103c7a231f?lnk=gst&q=luis+variables#25fe94103c7a231f

Short answer: you can update globals() with a dictionary, as follows:

globals().update( dict1 )

Then you'll have each key-value pair as variables in the global
namespace.
The question is: should you do it?

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


Re: to create variable from dict

2010-03-12 Thread Tim Chase

hiral wrote:

Is there any way to create variables which name matches with dict key?

For example:
dict1 = {"abc":'1", "def":"2"}

Now I am looking to have variable name abc and it's value be '1' etc.


1) you can't because "def" is a reserved word in Python.

2) why do you want to?  This seems to come up about every week or 
so and people STILL want to do it.  Search the archives...you 
won't have to go back too far.


3) once you have it, how do you plan to use the variables?  If 
you don't know what they'll be named ahead of time, how can you 
use them in your code


The usual answer is "don't do that -- just use them as a dict", 
or if you're trying to set up some constants, you can use


  abc, def_, ghi = 1, 2, 3

-tkc







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


Re: NoSQL Movement?

2010-03-12 Thread D'Arcy J.M. Cain
On Fri, 12 Mar 2010 01:05:27 -0800
Jonathan Gardner  wrote:
> Let me give you an example. I worked on a system that would load
> recipients for email campaigns into a database table. The SQL database
> was nice during the initial design and prototype stage because we
> could quickly adjust the tables to add or remove columns and try out
> different designs.. However, once our system got popular, the
> limitation was how fast we could load recipients into the database.

Just curious, what database were you using that wouldn't keep up with
you?  I use PostgreSQL and would never consider going back to flat
files.  The only thing I can think of that might make flat files faster
is that flat files are buffered whereas PG guarantees that your
information is written to disk before returning but if speed is more
important than 100% reliability you can turn that off and let PG use
the file system buffering just like flat files.

-- 
D'Arcy J.M. Cain  |  Democracy is three wolves
http://www.druid.net/darcy/|  and a sheep voting on
+1 416 425 1212 (DoD#0082)(eNTP)   |  what's for dinner.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Reverse engineering CRC?

2010-03-12 Thread Emile van Sebille

On 3/12/2010 3:24 AM Gregory Ewing said...

What confused me initially is that it seems to be adding
a few extra bytes to the checked data that aren't present
in the file. Figuring out what they're supposed to contain
is proving to be quite a headache...


Length?

Emile



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


Re: inspect.stack() and frame

2010-03-12 Thread Félix-Antoine Fortin
Thanks Gabriel, you resumed quite well what I did discovered after my
second post
by playing with the garbage collector module.

> (The garbage collector will,  
> eventually, break the cycle and free those objects, but not very soon).

I'm not very familiar with the Python garbage collector, so you may
excuse my
simple question, but how can it break the cycle? I guess the object
will be
freed at least when the program ends, but could it be before that? Is
there a
mechanisme in the garbage collector to detect circular references?

Felix


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


to create variable from dict

2010-03-12 Thread hiral
Hi,

Is there any way to create variables which name matches with dict key?

For example:
dict1 = {"abc":'1", "def":"2"}

Now I am looking to have variable name abc and it's value be '1' etc.

Pl. suggest.

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


python module/utility equivalent to 'time' (linux) and/or 'ntimer'(Windows)

2010-03-12 Thread hiral
Hi,

Is there any python module/utility available which would report the
time same as 'time' command in linux and/or report time same as
'ntimer' utility in Windows.

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


result of os.times() is different with 'time' command Options

2010-03-12 Thread hiral
Hi,

Python version: 2.6

Script:
def pt(start_time, end_time):
def ptime(time, time_str):
min, sec = divmod(time, 60)
hr, min = divmod(min, 60)
stmt = time_str + '\t'
if hr:
stmt += str(hr) + 'h'
stmt += str(min) + 'm' + str(sec) + 's'
print stmt

if start_time and end_time:
real_time  = end_time[4] - start_time[4]
ptime(real_time, "real")
user_time  = end_time[0] - start_time[0]
ptime(user_time, "user")
sys_time   = end_time[1] - start_time[1]
ptime(sys_time, "sys")

import os, subprocess
cmd = ['ls']
print cmd
t1 = os.times()
subprocess.call(cmd)
t2 = os.times()
pt(t1, t2)
print ".end"


Output:
real0.0m0.010002421s
user0.0m0.0s
sys 0.0m0.0s


Command:
$ time ls

Output:
real0m0.007s
user0m0.000s
sys 0m0.000s


Is this the intended behaviour?

As per the link  it was fixed in
python 2.5.

Can anybody help.

Thank you.




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


Re: StringChain -- a data structure for managing large sequences of chunks of bytes

2010-03-12 Thread MRAB

Steven D'Aprano wrote:

On Fri, 12 Mar 2010 00:11:37 -0700, Zooko O'Whielacronx wrote:


Folks:

Every couple of years I run into a problem where some Python code that
worked well at small scales starts burning up my CPU at larger scales,
and the underlying issue turns out to be the idiom of accumulating data
by string concatenation. 


I don't mean to discourage you, but the simple way to avoid that is not 
to accumulate data by string concatenation.


The usual Python idiom is to append substrings to a list, then once, at 
the very end, combine into a single string:



accumulator = []
for item in sequence:
accumulator.append(process(item))
string = ''.join(accumulator)



It just happened again
(http://foolscap.lothar.com/trac/ticket/149 ), and as usual it is hard
to make the data accumulator efficient without introducing a bunch of
bugs into the surrounding code.


I'm sorry, I don't agree about that at all. I've never come across a 
situation where I wanted to use string concatenation and couldn't easily 
modify it to use the list idiom above.


[...]

Here are some benchmarks generated by running python -OOu -c 'from
stringchain.bench import bench; bench.quick_bench()' as instructed by
the README.txt file.


To be taken seriously, I think you need to compare stringchain to the 
list idiom. If your benchmarks favourably compare to that, then it might 
be worthwhile.



IIRC, someone did some work on making concatenation faster by delaying
it until a certain threshold had been reached (in the string class
implementation).
--
http://mail.python.org/mailman/listinfo/python-list


Re: Need advice on starting a Python group

2010-03-12 Thread bartc


"gb345"  wrote in message 
news:hnb0d1$2e...@reader1.panix.com...



A friend of mine and I have been trying to start a
scientific-programming-oriented Python group in our school (of
medecine and bio research), with not much success.

The main problem is attendance.  Even though a *ton* of people have
told us that it's a great idea, that they're *very* interested,
and have asked to be added to our mailing list, the attendance to
our first few meeting has never been more than 5, including my
friend and I.  Last time just he and I showed up.

...

Still, we have a hard time finding volunteers.

And even when we've had volunteers, hardly anyone shows up!

Any suggestions would be appreciated.


Try and get a girl or two interested in coming to the meetings...

--
Bartc



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


Re: Python dos2unix one liner

2010-03-12 Thread Albert van der Horst
In article ,
Martin P. Hellwig  wrote:
>On 02/28/10 11:05, Stefan Behnel wrote:
>> Steven D'Aprano, 28.02.2010 09:48:
>>> There ought to be some kind of competition for the least efficient
>>> solution to programming problems
>>
>> That wouldn't be very interesting. You could just write a code generator
>> that spits out tons of garbage code including a line that solves the
>> problem, and then let it execute the code afterwards. That beast would
>> always win.
>>
>> Stefan
>>
>Well that would be an obvious rule that garbage code that does not
>contribute to the end result (ie can be taken out without affecting the
>end result) would not be allowed. Enforcing the rule is another beast
>though, but I would leave that to the competition.

Thinking of the international obfuscated c contest (iocc).
It is easy to make a mess of a program using the preprocessor.
It is also easy to preprocess then prettyprint the program.
If the result is not obfuscated, it impresses nobody.
Likewise the judges would think nothing of a program with garbage,
and would rate it low, so such rule is unnecessary.

>
>Though the idea of a code generator is solid, but instead of generating
>garbage, produces a virtual machine that implements a generator that
>produces a virtual machine, etc. etc.

That was actually done by Lennart Benschop. He made a Forth program
run by an interpreter written in C.
Although Forthers thought it was straightforward comprehensible
code, it was a winner in the iocc.

>
>--
>mph

Groetjes Albert

--
-- 
Albert van der Horst, UTRECHT,THE NETHERLANDS
Economic growth -- being exponential -- ultimately falters.
alb...@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst

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


Re: execute bash builtins in python

2010-03-12 Thread Steve Holden
alex goretoy wrote:
> hi,
> i'm trying to write a section of my program that needs to run bash
> builtin alias and declare, i've googled and tried every type of example
> i could find no to avail. this is what I've tried below and it doesn't
> work, is there a way for me to execute a bah builin from python? what i
> need is to take alias output and pipe it to another command with python
> and return the results to a string or list.
> 
 p1=Popen(["alias"],stdout=PIPE)
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/usr/lib/python2.6/subprocess.py", line 621, in __init__
> errread, errwrite)
>   File "/usr/lib/python2.6/subprocess.py", line 1126, in _execute_child
> raise child_exception
> OSError: [Errno 2] No such file or directory
> 
> if i add shell=True i get empty string and no thins error message
> 
 p1=Popen(["alias"],stdout=PIPE,shell=True)
 p1
> 
 p1.stdout.read()
> ''
> 
> thank you,
> -Alex Goretoy
> 
For shell=True I believe you should provide the command as a single
string, not a list of arguments.

>>> p1 = Popen("alias", stdout=PIPE, shell=True)
>>>

regards
 Steve
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
See PyCon Talks from Atlanta 2010  http://pycon.blip.tv/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS:http://holdenweb.eventbrite.com/

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


Re: Anything like "Effective Java" for Python?

2010-03-12 Thread Steve Holden
Neo wrote:
> I have learned java for half a year and now I want to learn Python,
> should I learn python 3k or the traditional version?
> 
That depends on whether you need to use specific libraries that haven't
yet been ported to Python 3. If so then start with Python 2. If not,
start with 3 - the differences are small enough that you can relatively
easily fall back to 2 if you need to get access to non-ported libraries.

regards
 Steve

> On Wed, Mar 10, 2010 at 7:19 AM, kj  wrote:
> 
> 
> 
> 
> Subject line pretty much says it all: is there a book like "Effective
> Java" for Python.  I.e. a book that assumes that readers are
> experienced programmers that already know the basics of the language,
> and want to focus on more advanced programming issues?
> 
> ~K
> --
> http://mail.python.org/mailman/listinfo/python-list
> 
> 


-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
See PyCon Talks from Atlanta 2010  http://pycon.blip.tv/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS:http://holdenweb.eventbrite.com/

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


Re: Need advice on starting a Python group

2010-03-12 Thread Steve Holden
Jean-Michel Pichavant wrote:
> News123 wrote:
>> Jonathan Gardner wrote:
>>  
>>> On Thu, Mar 11, 2010 at 6:57 AM, gb345  wrote:
>>>
 And even when we've had volunteers, hardly anyone shows up!

 Any suggestions would be appreciated.

   
>>> Two things: One, only you and your friend really care. Let that sink
>>> in. No one is going to carry the group but you two, at least
>>> initially.
>>>
>>> Two, there's a lot of people at movie theaters and the county fair.
>>> Why? Because it is interesting and fun. Scientists work the same way.
>>> Yes, a lot of people are interested in Python. Why don't you do a bit
>>> of snooping around and see what people want to know about?
>>>
>>> Let me give some examples:
>>>
>>> * Interactive numeric programming with Python
>>> * Rapid website development with Pylons (Trust me, everyone wants to
>>> make a website.) Show how you are showing off data from one of your
>>> experiments of projects and how easy it is to organize and manage
>>> data.
>>> * How you used Python on your latest and greatest project
>>>
>>> Don't expect the audience to participate, except to show up and ask
>>> questions.
>>>
>>> If you want to build a Python support group, then form an informal
>>> group with your friends. Start a public mailing list and offer Python
>>> advice and support for free. Integrate whatever code your org has with
>>> Python, and manage and maintain that code so others can use it.
>>>
>>> Finally, advertise. The more people see "Python", the more they will
>>> be interested. Coca-cola and Pepsi are really good at this!
>>>
>>> 
>>
>>
>> attendance will be very low and be sure nobody cares to check whether
>> anything happened on this group.
>>
>> My suggestion is:
>>
>>
>> I'd suggest to setup a group, to which one can subscribe with mail
>> notification and for all the old ones perhaps even via nntp ;-) and of
>> course via a web front end (though I personally hate web groups)
>>
>> Afterwards you can 'friendly-fore-subscribe' some collegues. ;-)
>> Just talk about your new cool group during lunch, etc.
>>
>> Be sure, that most will be to lazy to unsuscribe.
>>
>> Start discussing interesting topics on this group and then . . .
>> maybe others start joining. maybo nobody cares and you have just to
>> accept it.
>>
>> bye
>>
>>
>> N
>>   
> Python is not interesting enough by itself to grab students attention.
> It's just a tool to solve some technical problems.
> 
> So, either python has a direct benefit on the study itself (meaning it
> can help getting better results), or you'll have to make it intereseting
> as a hobbit. But python is not music, video, dance nor it is related to
> sport, sex or whatever things that usually interest people. So I really
> don't know how to make it interesting, I'm not sure it's even possible
> nor desirable.
> 
> Good luck anyway.
> 
> JM
> 
> 
All the advice you have had is good. You need to turn around your
enthusiasm and look at it from the potential visitor's point of view -
what's in it for them?

You don't say where you are (and your invalid domain doesn't really help
identify that), but if you have any of the superstars from the
scientific Python world around you, invite one of them as a guest speaker.

Take a look on the web - e.g. in pycon.blip.tv, where all the PyCon
talks for the last two years are available. Maybe you could start each
meeting by showing one of those videos? Also take a look to see what
SciPy conferences have made available (though I don't think they do
videos yet).

The PSF has invested hugely in making that information available, and
the more they get used the happier we will be. But mostly it's a matter
of focusing on what your community needs from the group, and providing that.

Good luck!

regards
 Steve
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
See PyCon Talks from Atlanta 2010  http://pycon.blip.tv/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS:http://holdenweb.eventbrite.com/

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


Re: Parsing Email Headers

2010-03-12 Thread Thomas Guettler
T wrote:
> Thanks for your suggestions!  Here's what seems to be working - it's
> basically the same thing I originally had, but first checks to see if
> the line is blank
> 
> response, lines, bytes = M.retr(i+1)
> # For each line in message
> for line in lines:
> if not line.strip():
> M.dele(i+1)
> break
> 
> emailMessage = email.message_from_string(line)
> # Get fields
> fields = emailMessage.keys()
> # If email contains "From" field
> if emailMessage.has_key("From"):
> # Get contents of From field
> from_field = emailMessage.__getitem__("From")

Hi T,

wait, this code looks strange.

You delete the email if it contains an empty line? I use something like this:

message='\n'.join(connection.retr(msg_num)[1])

Your code:
emailMessage = email.message_from_string(line)
create an email object from only *one* line!

You retrieve the whole message (you don't save bandwith), but maybe that's
what you want.


  Thomas

-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Need advice on starting a Python group

2010-03-12 Thread Jean-Michel Pichavant

News123 wrote:

Jonathan Gardner wrote:
  

On Thu, Mar 11, 2010 at 6:57 AM, gb345  wrote:


And even when we've had volunteers, hardly anyone shows up!

Any suggestions would be appreciated.

  

Two things: One, only you and your friend really care. Let that sink
in. No one is going to carry the group but you two, at least
initially.

Two, there's a lot of people at movie theaters and the county fair.
Why? Because it is interesting and fun. Scientists work the same way.
Yes, a lot of people are interested in Python. Why don't you do a bit
of snooping around and see what people want to know about?

Let me give some examples:

* Interactive numeric programming with Python
* Rapid website development with Pylons (Trust me, everyone wants to
make a website.) Show how you are showing off data from one of your
experiments of projects and how easy it is to organize and manage
data.
* How you used Python on your latest and greatest project

Don't expect the audience to participate, except to show up and ask questions.

If you want to build a Python support group, then form an informal
group with your friends. Start a public mailing list and offer Python
advice and support for free. Integrate whatever code your org has with
Python, and manage and maintain that code so others can use it.

Finally, advertise. The more people see "Python", the more they will
be interested. Coca-cola and Pepsi are really good at this!





attendance will be very low and be sure nobody cares to check whether
anything happened on this group.

My suggestion is:


I'd suggest to setup a group, to which one can subscribe with mail
notification and for all the old ones perhaps even via nntp ;-) and of
course via a web front end (though I personally hate web groups)

Afterwards you can 'friendly-fore-subscribe' some collegues. ;-)
Just talk about your new cool group during lunch, etc.

Be sure, that most will be to lazy to unsuscribe.

Start discussing interesting topics on this group and then . . .
maybe others start joining. maybo nobody cares and you have just to
accept it.

bye


N
  
Python is not interesting enough by itself to grab students attention. 
It's just a tool to solve some technical problems.


So, either python has a direct benefit on the study itself (meaning it 
can help getting better results), or you'll have to make it intereseting 
as a hobbit. But python is not music, video, dance nor it is related to 
sport, sex or whatever things that usually interest people. So I really 
don't know how to make it interesting, I'm not sure it's even possible 
nor desirable.


Good luck anyway.

JM


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


Unicode characters in btye-strings

2010-03-12 Thread Steven D'Aprano
I know this is wrong, but I'm not sure just how wrong it is, or why. 
Using Python 2.x:

>>> s = "éâÄ"
>>> print s
éâÄ
>>> len(s)
6
>>> list(s)
['\xc3', '\xa9', '\xc3', '\xa2', '\xc3', '\x84']

Can somebody explain what happens when I put non-ASCII characters into a 
non-unicode string? My guess is that the result will depend on the 
current encoding of my terminal.

In this case, my terminal is set to UTF-8. If I change it to ISO 8859-1, 
and repeat the above, I get this:

>>> list("éâÄ")
['\xe9', '\xe2', '\xc4']

If I do this:

>>> s = u"éâÄ"
>>> s.encode('utf-8')
'\xc3\xa9\xc3\xa2\xc3\x84'
>>> s.encode('iso8859-1')
'\xe9\xe2\xc4'

which at least explains why the bytes have the values which they do.


Thank you,



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


Re: show image in python

2010-03-12 Thread News123
Philip Semanchuk wrote:
> 
> On Mar 10, 2010, at 5:03 PM, mohamed issolah wrote:
> 
>> Hey, This is my program
>>

>> 18 def Creeimg():
>> 19 """transforme matrice en image"""
>> 20 img = Image.new ("L",(8,8))
>> 21 matrix = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
>> 22 img.putdata(matrix)
>> 23 img.show()
>> 24 img.save(fp="./ana.bmp")
>> 25

>>
>> My probeleme : In line 23 "img.show()" Don't work, normally I show the
>> image

Image show is implemented rather half heartedly (at least on linux)

a potential reasons is:
- you didn not install the correct image viewer tool (You should see an
error message though". Then you could try to install the tool, that
python did not find.


depending on the platform, you might have bugs, that don't allow to view
more than one image at a time / etc.

potentially you might be better of by just using
a hand rolled os.system()
or subprocess.Popen call


bye

N





>> but it's not work, but strangely in line 24 "img.save(fp="./ana.bmp")"
>> it's
>> work
>> WHERE IS THE PROBLEME.
>>
>> I have this error in shell : "(eog:3176): GLib-WARNING **: GError set
>> over
>> the top of a previous GError or uninitialized memory.
>> This indicates a bug in someone's code. You must ensure an error is NULL
>> before it's set.
>> The overwriting error message was: Error in getting image file info "
>>
>>
>> os: ubuntu 9.10
> 
> Hi issolah,
> I don't know what your problem is but I have a few suggestions --
> 1) You say that img.show() doesn't work. How does it fail? Is that where
> you get the GLib warning?
> 2) I'm glad you posted your code, but because it has line numbers, it's
> awkward to copy & paste into a local example. Please show your code
> without line numbers.
> 
> I'm unfamiliar with PIL, so this is just a wild guess, but based on the
> GLib error it seems like you haven't initialized something properly.
> Sorry I couldn't be more helpful. Maybe someone who knows more will answer.
> 
> Good luck
> Philip
> 
> 
> 
> 
> 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python, Reportlabs, Pil and Windows 7 (64bit)

2010-03-12 Thread Robin Becker

On 11/03/2010 18:00, Martin v. Loewis wrote:



I have a Windows 7 (64bit AMD) machine

..



Perhaps some expert on the python list knows which versions of VS
support 64bit; I do have VS 2005/2008 etc, but I'll probably need to set
up a 64bit machine to see if they will install on a 64bit architecture.


For Python 2.6 and later, use VS 2008. This comes with an AMD64
compiler. You technically don't need a 64-bit Windows, as it supports
cross-compilation (but you would need a 64-bit Windows to test it).

I personally build Python on a 32-bit machine, and move the MSI to a
64-bit machine for testing.



OK I've got the VC2008 64bit tools installed on my 32bit build platform, but I'm 
getting build errors because of missing libraries. I assume that's because I 
don't have the python amd64 runtime libraries/dlls etc etc since the errors are 
looking like this


_rl_accel.obj : error LNK2019: unresolved external symbol __imp_Py_FindMethod 
referenced in function Box_getattr
_rl_accel.obj : error LNK2019: unresolved external symbol __imp_PyObject_Init 
referenced in function Box
_rl_accel.obj : error LNK2019: unresolved external symbol __imp_PyObject_Malloc 
referenced in function Box
_rl_accel.obj : error LNK2019: unresolved external symbol __imp_PyList_Type 
referenced in function BoxList_init
_rl_accel.obj : error LNK2019: unresolved external symbol __imp_Py_FatalError 
referenced in function init_rl_accel
_rl_accel.obj : error LNK2019: unresolved external symbol __imp_PyType_Ready 
referenced in function init_rl_accel
_rl_accel.obj : error LNK2019: unresolved external symbol __imp_PyType_Type 
referenced in function init_rl_accel
_rl_accel.obj : error LNK2019: unresolved external symbol 
__imp_PyModule_AddObject referenced in function init_rl_accel
_rl_accel.obj : error LNK2019: unresolved external symbol 
__imp_PyErr_NewException referenced in function init_rl_accel
_rl_accel.obj : error LNK2019: unresolved external symbol 
__imp_Py_InitModule4_64 referenced in function init_rl_accel

build\lib.win-amd64-2.6\_rl_accel.pyd : fatal error LNK1120: 69 unresolved 
externals

I assume I can get those from a working Python amd64 install and stuff on one of 
the compiler paths somehow.

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


Re: Need advice on starting a Python group

2010-03-12 Thread News123
Jonathan Gardner wrote:
> On Thu, Mar 11, 2010 at 6:57 AM, gb345  wrote:
>> And even when we've had volunteers, hardly anyone shows up!
>>
>> Any suggestions would be appreciated.
>>
> 
> Two things: One, only you and your friend really care. Let that sink
> in. No one is going to carry the group but you two, at least
> initially.
> 
> Two, there's a lot of people at movie theaters and the county fair.
> Why? Because it is interesting and fun. Scientists work the same way.
> Yes, a lot of people are interested in Python. Why don't you do a bit
> of snooping around and see what people want to know about?
> 
> Let me give some examples:
> 
> * Interactive numeric programming with Python
> * Rapid website development with Pylons (Trust me, everyone wants to
> make a website.) Show how you are showing off data from one of your
> experiments of projects and how easy it is to organize and manage
> data.
> * How you used Python on your latest and greatest project
> 
> Don't expect the audience to participate, except to show up and ask questions.
> 
> If you want to build a Python support group, then form an informal
> group with your friends. Start a public mailing list and offer Python
> advice and support for free. Integrate whatever code your org has with
> Python, and manage and maintain that code so others can use it.
> 
> Finally, advertise. The more people see "Python", the more they will
> be interested. Coca-cola and Pepsi are really good at this!
> 


attendance will be very low and be sure nobody cares to check whether
anything happened on this group.

My suggestion is:


I'd suggest to setup a group, to which one can subscribe with mail
notification and for all the old ones perhaps even via nntp ;-) and of
course via a web front end (though I personally hate web groups)

Afterwards you can 'friendly-fore-subscribe' some collegues. ;-)
Just talk about your new cool group during lunch, etc.

Be sure, that most will be to lazy to unsuscribe.

Start discussing interesting topics on this group and then . . .
maybe others start joining. maybo nobody cares and you have just to
accept it.

bye


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


Re: Reverse engineering CRC?

2010-03-12 Thread Gregory Ewing

Lawrence D'Oliveiro wrote:

They could be using a strong cryptographic hash and truncating it to 16 bits 
or something.


In which case you’ve got your work cut out for you...


Nope, I've determined that it's actually a pretty standard
CRC, and it's even using one of the standard polynomials,
0x8005. I'll explain the details of how I figured that
out in my essay.

What confused me initially is that it seems to be adding
a few extra bytes to the checked data that aren't present
in the file. Figuring out what they're supposed to contain
is proving to be quite a headache...

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


Re: Python, Reportlabs, Pil and Windows 7 (64bit)

2010-03-12 Thread Robin Becker
Following the information from MvL I will try and get the 2.6 pyds built for 
amd64, I see that there's a cross platform compile technique for distutils, but 
am not sure if it applies to bdist_winexe etc etc. I'll have a go at this next week.

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


Re: Need advice on starting a Python group

2010-03-12 Thread Jonathan Gardner
On Thu, Mar 11, 2010 at 6:57 AM, gb345  wrote:
>
> And even when we've had volunteers, hardly anyone shows up!
>
> Any suggestions would be appreciated.
>

Two things: One, only you and your friend really care. Let that sink
in. No one is going to carry the group but you two, at least
initially.

Two, there's a lot of people at movie theaters and the county fair.
Why? Because it is interesting and fun. Scientists work the same way.
Yes, a lot of people are interested in Python. Why don't you do a bit
of snooping around and see what people want to know about?

Let me give some examples:

* Interactive numeric programming with Python
* Rapid website development with Pylons (Trust me, everyone wants to
make a website.) Show how you are showing off data from one of your
experiments of projects and how easy it is to organize and manage
data.
* How you used Python on your latest and greatest project

Don't expect the audience to participate, except to show up and ask questions.

If you want to build a Python support group, then form an informal
group with your friends. Start a public mailing list and offer Python
advice and support for free. Integrate whatever code your org has with
Python, and manage and maintain that code so others can use it.

Finally, advertise. The more people see "Python", the more they will
be interested. Coca-cola and Pepsi are really good at this!

-- 
Jonathan Gardner
jgard...@jonathangardner.net
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: NoSQL Movement?

2010-03-12 Thread Jonathan Gardner
On Wed, Mar 3, 2010 at 2:41 PM, Avid Fan  wrote:
> Jonathan Gardner wrote:
>>
>> I see it as a sign of maturity with sufficiently scaled software that
>> they no longer use an SQL database to manage their data. At some point
>> in the project's lifetime, the data is understood well enough that the
>> general nature of the SQL database is unnecessary.
>>
>
> I am really struggling to understand this concept.
>
> Is it the normalised table structure that is in question or the query
> language?
>
> Could you give some sort of example of where SQL would not be the way to go.
>   The only things I can think of a simple flat file databases.

Sorry for the late reply.

Let's say you have an application that does some inserts and updates
and such. Eventually, you are going to run into a limitation with the
number of inserts and updates you can do at once. The typical solution
to this is to shard your database. However, there are other solutions,
such as storing the files in a different kind of database, one which
is less general but more efficient for your particular data.

Let me give you an example. I worked on a system that would load
recipients for email campaigns into a database table. The SQL database
was nice during the initial design and prototype stage because we
could quickly adjust the tables to add or remove columns and try out
different designs.. However, once our system got popular, the
limitation was how fast we could load recipients into the database.
Rather than make our DB bigger or shard the data, we discovered that
storing the recipients outside of the database in flat files was the
precise solution we needed. Each file represented a different email
campaign. The nature of the data was that we didn't need random
access, just serial access. Storing the data this way also meant
sharding the data was almost trivial. Now, we can load a massive
number of recipients in parallel.

You are going to discover certain patterns in how your data is used
and those patterns may not be best served by a generic relational
database. The relational database will definitely help you discover
and even experiment with these patterns, but eventually, you will find
its limits.

-- 
Jonathan Gardner
jgard...@jonathangardner.net
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: bypass UAC control through python script (to be run from batchfile)

2010-03-12 Thread rizwanahme...@gmail.com

Hi Michel. what is this 'resident soff' script, i cannot find it on
google. Secondly if i was to install something in admin mode, then i
would have installed the application i want to install. The actual
problem is that i dont want to manually run something with admin
rights and install.
still havent got the solution
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Anything like "Effective Java" for Python?

2010-03-12 Thread Neo
I have learned java for half a year and now I want to learn Python, should I
learn python 3k or the traditional version?

On Wed, Mar 10, 2010 at 7:19 AM, kj  wrote:

>
>
>
> Subject line pretty much says it all: is there a book like "Effective
> Java" for Python.  I.e. a book that assumes that readers are
> experienced programmers that already know the basics of the language,
> and want to focus on more advanced programming issues?
>
> ~K
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: file seek is slow

2010-03-12 Thread Stefan Behnel

Metalone, 11.03.2010 23:57:

I just tried the seek test with Cython.
Cython fseek() : 1.059 seconds.  30% slower than 'C'
Python f.seek  : 1.458 secondds. 80% slower than 'C'.

It is amazing to me that Cython generates a 'C' file that is 1478
lines.


Well, it generated an optimised Python interface for your module and made 
it compilable in CPython 2.3 through 3.2. It doesn't look like your C 
module features that. ;)




#Cython code

import time

cdef int SEEK_SET = 0

cdef extern from "stdio.h":
 void* fopen(char* filename, char* mode)
 int fseek(void*, long, int)


Cython ships with a stdio.pxd that you can cimport. It looks like it 
doesn't currently define fseek(), but it defines at least fopen() and FILE. 
Patches are always welcome.




def main():
 cdef void* f1 = fopen('video.txt', 'rb')
 cdef int i=100
 t0 = time.clock()
 while i>  0:
fseek(f1, 0, SEEK_SET)
i -= 1
 delta = time.clock() - t0


Note that the call to time.clock() takes some time, too, so it's not 
surprising that this is slower than hand-written C code. Did you test how 
it scales?


Also, did you look at the generated C code or the annotated Cython code 
(cython -a)? Did you make sure both were compiled with the same CFLAGS?


Also, any reason you're not using a for-in-xrange loop? It shouldn't make a 
difference in speed, it's just more common. You even used a for loop in 
your C code.


Finally, I'm not sure why you think that these 30% matter at all. In your 
original post, you even state that seek-time isn't the "deal breaker", so 
maybe you should concentrate on the real issues?


Stefan

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


Re: StringChain -- a data structure for managing large sequences of chunks of bytes

2010-03-12 Thread Steven D'Aprano
On Fri, 12 Mar 2010 00:11:37 -0700, Zooko O'Whielacronx wrote:

> Folks:
> 
> Every couple of years I run into a problem where some Python code that
> worked well at small scales starts burning up my CPU at larger scales,
> and the underlying issue turns out to be the idiom of accumulating data
> by string concatenation. 

I don't mean to discourage you, but the simple way to avoid that is not 
to accumulate data by string concatenation.

The usual Python idiom is to append substrings to a list, then once, at 
the very end, combine into a single string:


accumulator = []
for item in sequence:
accumulator.append(process(item))
string = ''.join(accumulator)


> It just happened again
> (http://foolscap.lothar.com/trac/ticket/149 ), and as usual it is hard
> to make the data accumulator efficient without introducing a bunch of
> bugs into the surrounding code.

I'm sorry, I don't agree about that at all. I've never come across a 
situation where I wanted to use string concatenation and couldn't easily 
modify it to use the list idiom above.

[...]
> Here are some benchmarks generated by running python -OOu -c 'from
> stringchain.bench import bench; bench.quick_bench()' as instructed by
> the README.txt file.

To be taken seriously, I think you need to compare stringchain to the 
list idiom. If your benchmarks favourably compare to that, then it might 
be worthwhile.



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


Threading, Queue for a function so it only runs once at a time.

2010-03-12 Thread John P.
Hi, 

Im programming a simple webcrawler with threading for the fun of it, which
is inserting the data fetch into a mysql database, but after continuously
cause my mysql server to produce error during database queries (i assume
its cause because of the many execution at the same time.) the scipt
produces errors.

I figured out i need some kind of queue for the function i use to insert
into the database, to make sure its only called once at a time.

I have looked at the Queue module but its for more complicated than my
current python skills can cope with. :)

Would somebody please help me out here?

Thanks.

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


Re: file seek is slow

2010-03-12 Thread Stefan Behnel

CHEN Guang, 12.03.2010 08:51:

Metalone wrote:

I just tried the seek test with Cython.
Cython fseek() : 1.059 seconds.  30% slower than 'C'
Python f.seek  : 1.458 secondds. 80% slower than 'C'.

It is amazing to me that Cython generates a 'C' file that is 1478
lines.


PythoidC ( http://pythoidc.googlecode.com ) generates the shortest 'C' file.
PythoidC is the C language like the Python, by the Python and for the Python.


Except that it's not a language but rather a syntax converter, i.e. it 
doesn't really add any features to the C language but rather restricts 
Python syntax to C language features (plus a bit of header file 
introspection, it seems, but C's preprocessor has a bit of that, too).


Stefan

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