Saturday, March 13, 2010

comp.lang.python - 26 new messages in 12 topics - digest

comp.lang.python
http://groups.google.com/group/comp.lang.python?hl=en

comp.lang.python@googlegroups.com

Today's topics:

* python to exe - 7 messages, 6 authors
http://groups.google.com/group/comp.lang.python/t/52eb42cf1b898184?hl=en
* Python for newbies (Pythno users group in Macedonia) - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.python/t/0402ea4f5453ad53?hl=en
* to create variable from dict - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/9a2ccf6e5c80789b?hl=en
* execute bash builtins in python - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/566f672d7f34e3ab?hl=en
* print formatting - 3 messages, 3 authors
http://groups.google.com/group/comp.lang.python/t/42e63e3a53f03593?hl=en
* Reverse engineering CRC? - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/b22db1e3e63db596?hl=en
* Question about typing: ints/floats - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/1692af088221a9d0?hl=en
* building a dict - 6 messages, 5 authors
http://groups.google.com/group/comp.lang.python/t/d080f2d5dd29beab?hl=en
* Use python and Jython together? (newbie) - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/1ec71759062b2201?hl=en
* Ideas for creating processes - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/104bababcbab6607?hl=en
* Work at Home - Earn 50,000 Weekly Without Investment Its Not A Fake, 100%
Earning Guarantee - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/5065f5126e462427?hl=en
* wx error, I suspect my class - 1 messages, 1 author
http://groups.google.com/group/comp.lang.python/t/6d211d7cdd75842d?hl=en

==============================================================================
TOPIC: python to exe
http://groups.google.com/group/comp.lang.python/t/52eb42cf1b898184?hl=en
==============================================================================

== 1 of 7 ==
Date: Fri, Mar 12 2010 10:47 pm
From: Steven D'Aprano


On Fri, 12 Mar 2010 22:26:34 -0600, John Bokma wrote:

> Gabriel Genellina <gagsl-py2@yahoo.com.ar> writes:
>
>> On 13 mar, 00:26, Robin <rob...@cnsp.com> 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


== 2 of 7 ==
Date: Sat, Mar 13 2010 1:38 am
From: Gib Bogle


Steven D'Aprano wrote:

> 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 like this version:

Light a man a fire, and you keep him warm for hours. Set a man on fire, and you
keep him warm for the rest of his life.

;-)


== 3 of 7 ==
Date: Sat, Mar 13 2010 2:35 am
From: "Alf P. Steinbach"


* Gib Bogle:
> Steven D'Aprano wrote:
>
>> 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 like this version:
>
> Light a man a fire, and you keep him warm for hours. Set a man on fire,
> and you keep him warm for the rest of his life.
>
> ;-)

Hey! I was going to post that! And there it was, in the next article... :-)

Cheers,

- Alf


== 4 of 7 ==
Date: Sat, Mar 13 2010 2:58 am
From: Mark Lawrence


Gib Bogle wrote:
> Steven D'Aprano wrote:
>
>> 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 like this version:
>
> Light a man a fire, and you keep him warm for hours. Set a man on fire,
> and you keep him warm for the rest of his life.
>
> ;-)

I'm certain that members of the Guinea Pig Club might have something to
say on that one, see :-
http://en.wikipedia.org/wiki/Guinea_Pig_Club

== 5 of 7 ==
Date: Sat, Mar 13 2010 5:11 am
From: Steve Holden


Gib Bogle wrote:
> Steven D'Aprano wrote:
>
>> 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 like this version:
>
> Light a man a fire, and you keep him warm for hours. Set a man on fire,
> and you keep him warm for the rest of his life.
>
> ;-)

I like "Give a man a fish, and he eats for a day. Teach a man to fish
and he will bore you with stories of the one that got away for the rest
of his life".

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/

== 6 of 7 ==
Date: Sat, Mar 13 2010 5:09 am
From: Steve Holden


John Bokma wrote:
> Gabriel Genellina <gagsl-py2@yahoo.com.ar> writes:
>
>> On 13 mar, 00:26, Robin <rob...@cnsp.com> wrote:
>>
>>> Does anyone know of a good python to stand alone exe compiler?
>> http://tinyurl.com/...
>
> Wow, pathetic fuck. You don't have to post you know.
>
And you don't have to give Google a second chance at indexing the URL,
but we all make mistakes.

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/

== 7 of 7 ==
Date: Sat, Mar 13 2010 5:45 am
From: python@bdurham.com


Robin,

> do you of an alternate compilter it doesn't work (py2exe) on my windows 7 box

I can assure you that Py2exe does work on Windows 7 (my firm develops
commercial Python applications packaged using Py2exe running on Windows
7), but it does take a bit of fiddling and some patience. Join the
py2exe newsgroup and post your problems there.
https://lists.sourceforge.net/lists/listinfo/py2exe-users

You may also want to google 'Gui2exe'. This is a free front-end to
Py2exe that you can use to generate your Py2exe setup.py scripts. Note
that Gui2exe requires wxPython (free) to run.

Finally, make sure you are trying to compile 32-bit Python 2.x code. I
don't think py2exe supports Python 3.x or 64-bit versions of Python yet.

> Nope; py2exe is pretty much the go-to tool for this.

I hear great things about PyInstaller. The project is not dead - make
sure you use the latest version in the SVN.

Search stackoverflow.com for positive feedback and tips on PyInstaller.
Its on our plate to take a good look this product 'one of these days'.

Good luck!

Malcolm

==============================================================================
TOPIC: Python for newbies (Pythno users group in Macedonia)
http://groups.google.com/group/comp.lang.python/t/0402ea4f5453ad53?hl=en
==============================================================================

== 1 of 2 ==
Date: Fri, Mar 12 2010 11:20 am
From: Дамјан Георгиевски


Hi all,
we are starting with bi-monthly Python User Group meetings in Skopje,
Macedonia. The meetings are targeted for both beginners and more
experienced users.

The basic idea is to have an 1 hour presentation at the start for the
beginners and an 1 hour ad-hoc discussion about projects, applications,
interesting stuff etc.

I'd like to gather some guidance/experince/thoughts about some beginner
oriented python lectures we could use?

My first idea was to do something like the "Python module of the Week",
but maybe there's a better approach?

thanks

--
damjan


== 2 of 2 ==
Date: Sat, Mar 13 2010 5:15 am
From: Steve Holden


Дамјан Георгиевски wrote:
> Hi all,
> we are starting with bi-monthly Python User Group meetings in Skopje,
> Macedonia. The meetings are targeted for both beginners and more
> experienced users.
>
> The basic idea is to have an 1 hour presentation at the start for the
> beginners and an 1 hour ad-hoc discussion about projects, applications,
> interesting stuff etc.
>
> I'd like to gather some guidance/experince/thoughts about some beginner
> oriented python lectures we could use?
>
> My first idea was to do something like the "Python module of the Week",
> but maybe there's a better approach?
>
> thanks
>
If you are all English-speakers then perhaps you could consider showing
a PyCon video - see

http://pycon.blip.tv

Good luck with the group. I hope to see PyCon Macedonia emerging before
too long!

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/


==============================================================================
TOPIC: to create variable from dict
http://groups.google.com/group/comp.lang.python/t/9a2ccf6e5c80789b?hl=en
==============================================================================

== 1 of 1 ==
Date: Sat, Mar 13 2010 3:41 am
From: Andreas Waldenburger


On Fri, 12 Mar 2010 06:50:18 -0800 (PST) Luis M. González
<luismgz@gmail.com> wrote:

> The question is: should you do it?

And the answer is: No.

And the usual disclaimer is: (Unless you *know* it's the best possible
solution to your problem.)

/W

--
INVALID? DE!


==============================================================================
TOPIC: execute bash builtins in python
http://groups.google.com/group/comp.lang.python/t/566f672d7f34e3ab?hl=en
==============================================================================

== 1 of 1 ==
Date: Sat, Mar 13 2010 5:08 am
From: Steve Holden


alex goretoy wrote:
> I found this to be even better; maybe someone will find this useful, who
> knows.
> just export PS1, duh
> Popen(["bash -c 'export PS1='python'; source
> $HOME/.bashrc;alias'"],shell=True,stdout=PIPE).stdout.read()
>
Try using an interactive shell:

>>> from subprocess import *
>>> p1 = Popen("bash -i -c alias", stdout=PIPE, shell=True)
>>> p1.stdout.read()
"alias ls='ls --color=auto'\n"
>>>

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/


==============================================================================
TOPIC: print formatting
http://groups.google.com/group/comp.lang.python/t/42e63e3a53f03593?hl=en
==============================================================================

== 1 of 3 ==
Date: Sat, Mar 13 2010 5:16 am
From: vsoler


Hello,

My script contains a print statement:

print '%40s %15d' % (k, m)

However,

1- the string is right adjusted, and I would like it left
adjusted
2- the number is a decimal number, and I would like it with
the thousands separator and 2 decimals

If possible, the thousands separator and the decimal separator should
use my local settings.

Is there any way to achieve this?


== 2 of 3 ==
Date: Sat, Mar 13 2010 5:31 am
From: Steve Holden


vsoler wrote:
> Hello,
>
> My script contains a print statement:
>
> print '%40s %15d' % (k, m)
>
> However,
>
> 1- the string is right adjusted, and I would like it left
> adjusted
> 2- the number is a decimal number, and I would like it with
> the thousands separator and 2 decimals
>
> If possible, the thousands separator and the decimal separator should
> use my local settings.
>
> Is there any way to achieve this?

Left-alignment is achieved by using a negative width.

You can use the locale module to generate thousands-separated numeric
string representations:

>>> from locale import *
>>> setlocale(LC_ALL, '') # locale is otherwise 'C'
'en_US.UTF-8'
>>> locale.format("%12.3f", 123456.789, grouping=False)
' 123456.789'
>>> locale.format("%12.3f", 123456.789, grouping=True)
' 123,456.789'

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/

== 3 of 3 ==
Date: Sat, Mar 13 2010 5:37 am
From: Peter Otten <__peter__@web.de>


vsoler wrote:

> My script contains a print statement:
>
> print '%40s %15d' % (k, m)
>
> However,
>
> 1- the string is right adjusted, and I would like it left
> adjusted
> 2- the number is a decimal number, and I would like it with
> the thousands separator and 2 decimals
>
> If possible, the thousands separator and the decimal separator should
> use my local settings.
>
> Is there any way to achieve this?

>>> import locale
>>> locale.setlocale(locale.LC_ALL, "")
'de_DE.UTF-8'

Traditional:
>>> print '%-40s|%15s' % (k, locale.format("%d", m, grouping=True))
hello | 1.234.567

New:
>>> "{0:<40} {1:15n}".format(k, m)
'hello 1.234.567'

See also:
http://docs.python.org/dev/py3k/library/string.html#formatstrings

Peter

==============================================================================
TOPIC: Reverse engineering CRC?
http://groups.google.com/group/comp.lang.python/t/b22db1e3e63db596?hl=en
==============================================================================

== 1 of 1 ==
Date: Sat, Mar 13 2010 7:29 am
From: Albert van der Horst


In article <7vj7fdFnnjU1@mid.individual.net>,
Gregory Ewing <greg.ewing@canterbury.ac.nz> wrote:
>Given some known data/crc pairs, how feasible is it to
>figure out the polynomial being used to generate the crc?
>
>In the case I'm looking at, it appears that the crc
>size may be at least 24 bits, so just trying all possible
>polynomials probably isn't doable.
>
>An article I found hints at the possibility of using
>GCDs to make the search more efficient, but doesn't go
>into any details. Anyone know of any literature about
>this?
>
>If it helps, I have the ability to generate test cases
>with known message contents to some extent, although
>I don't have complete control over the contents. Also
>it's a manual process, so generating large numbers of
>them automatically isn't an option.

If it is really a CRC, it is doable.

You can have an indication, if the intention is to detect
machine errors (transmission or disk errors) or they want
you to prevent tampering with the file.
In the latter case it may be a one-way hash. Then it is near
impossible, as this is the design criterion for a one-way hash.

>--
>Greg

Groetjes Albert

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


==============================================================================
TOPIC: Question about typing: ints/floats
http://groups.google.com/group/comp.lang.python/t/1692af088221a9d0?hl=en
==============================================================================

== 1 of 1 ==
Date: Sat, Mar 13 2010 6:53 am
From: Albert van der Horst


In article <mailman.266.1267666113.23598.python-list@python.org>,
MRAB <python@mrabarnett.plus.com> wrote:
>Zeeshan Quireshi wrote:
>> On Mar 3, 6:45 pm, Wells <thewellsoli...@gmail.com> wrote:
>>> This seems sort of odd to me:
>>>
>>>>>> a = 1
>>>>>> a += 1.202
>>>>>> a
>>> 2.202
>>>
>>> Indicates that 'a' was an int that was implicitly casted to a float.
>>> But:
>>>
>>>>>> a = 1
>>>>>> b = 3
>>>>>> a / b
>>> 0
>>>
>>> This does not implicitly do the casting, it treats 'a' and 'b' as
>>> integers, and the result as well. Changing 'b' to 3.0 will yield a
>>> float as a result (0.33333333333333331)
>>>
>>> Is there some way to explain the consistency here? Does python
>>> implicitly change the casting when you add variables of a different
>>> numeric type?
>>>
>>> Anyway, just curiosity more than anything else. Thanks!
>>
>> Python, like most other languages performs only integer division when
>> both the operands are ints. So only if one of the types is a flot or
>> you explicitly cast your expression to be a double, then the value
>> will be a fraction. otherwise you will the quotient.
>
>int + int gives int
>float + float gives float
>int + float gives float

You skip a step here that the OP may have missed.
a = 1
a += 1.222
This invokes the calculation
1 + 1.222
which is int + float.

Groetjes Albert

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


==============================================================================
TOPIC: building a dict
http://groups.google.com/group/comp.lang.python/t/d080f2d5dd29beab?hl=en
==============================================================================

== 1 of 6 ==
Date: Sat, Mar 13 2010 7:05 am
From: vsoler


Say that "m" is a tuple of 2-tuples

m=(('as',3), ('ab',5), (None, 1), ('as',None), ('as',6))

and I need to build a "d" dict where each key has an associated list
whose first element is the count, and the second is the sum. If a 2-
tuple contains a None value, it should be discarded.

The expected result is:
d={'as':[2, 9], 'ab': [1,5]}

How should I proceed? So far I have been unsuccessful. I have tried
with a "for" loop.

Thank you for your help


== 2 of 6 ==
Date: Sat, Mar 13 2010 7:25 am
From: Jon Clements


On 13 Mar, 15:05, vsoler <vicente.so...@gmail.com> wrote:
> Say that "m" is a tuple of 2-tuples
>
> m=(('as',3), ('ab',5), (None, 1), ('as',None), ('as',6))
>
> and I need to build a "d" dict where each key has an associated list
> whose first element is the count, and the second is the sum. If a 2-
> tuple contains a None value, it should be discarded.
>
> The expected result is:
> d={'as':[2, 9], 'ab': [1,5]}
>
> How should I proceed? So far I have been unsuccessful. I have tried
> with a "for" loop.
>
> Thank you for your help

Something like:

d = defaultdict( lambda: [0,0] )
for key, val in filter(lambda L: not any(i is None for i in L), m):
d[key][0] += 1
d[key][1] += val

hth

Jon


== 3 of 6 ==
Date: Sat, Mar 13 2010 7:28 am
From: Patrick Maupin


On Mar 13, 9:05 am, vsoler <vicente.so...@gmail.com> wrote:
> Say that "m" is a tuple of 2-tuples
>
> m=(('as',3), ('ab',5), (None, 1), ('as',None), ('as',6))
>
> and I need to build a "d" dict where each key has an associated list
> whose first element is the count, and the second is the sum. If a 2-
> tuple contains a None value, it should be discarded.
>
> The expected result is:
> d={'as':[2, 9], 'ab': [1,5]}
>
> How should I proceed? So far I have been unsuccessful. I have tried
> with a "for" loop.

Post your first try at a for loop, and people might be willing to
point out problems, but this is such a basic for loop that it is
unlikely that anybody is going to write your ENTIRE homework for you.

Regards,
Pat


== 4 of 6 ==
Date: Sat, Mar 13 2010 7:36 am
From: Steve Holden


vsoler wrote:
> Say that "m" is a tuple of 2-tuples
>
> m=(('as',3), ('ab',5), (None, 1), ('as',None), ('as',6))
>
> and I need to build a "d" dict where each key has an associated list
> whose first element is the count, and the second is the sum. If a 2-
> tuple contains a None value, it should be discarded.
>
> The expected result is:
> d={'as':[2, 9], 'ab': [1,5]}
>
> How should I proceed? So far I have been unsuccessful. I have tried
> with a "for" loop.
>
> Thank you for your help

Here's a fairly simple-minded approach using a defaultdict, which calls
the dflt() function to create a value when the key is absent.

>>> from collections import defaultdict
>>> def dflt():
... return [0, 0]
...
>>> m = (('as',3), ('ab',5), (None, 1), ('as',None), ('as',6))
>>> d = defaultdict(dflt)
>>> for key, n in m:
... if key is not None and n is not None:
... c, t = d[key]
... d[key] = [c+1, t+n]
...
>>> d
defaultdict(<function dflt at 0x7f0bcb1b0ed8>,
{'as': [2, 9], 'ab': [1, 5]})
>>>

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/

== 5 of 6 ==
Date: Sat, Mar 13 2010 7:58 am
From: Jon Clements


On 13 Mar, 15:28, Patrick Maupin <pmau...@gmail.com> wrote:
> On Mar 13, 9:05 am, vsoler <vicente.so...@gmail.com> wrote:
>
> > Say that "m" is a tuple of 2-tuples
>
> > m=(('as',3), ('ab',5), (None, 1), ('as',None), ('as',6))
>
> > and I need to build a "d" dict where each key has an associated list
> > whose first element is the count, and the second is the sum. If a 2-
> > tuple contains a None value, it should be discarded.
>
> > The expected result is:
> > d={'as':[2, 9], 'ab': [1,5]}
>
> > How should I proceed? So far I have been unsuccessful. I have tried
> > with a "for" loop.
>
> Post your first try at a for loop, and people might be willing to
> point out problems, but this is such a basic for loop that it is
> unlikely that anybody is going to write your ENTIRE homework for you.
>
> Regards,
> Pat

I was thinking it's possibly homework, but looking at previous posts
it's fairly unlikely.

(If it is, then mea culpa, but as Steve has replied, I think I'll
manage to sleep tonight not worrying about the influx of uneducated,
incompetent and otherwise useless developers to the market).

However, they're receiving some 'elegant' solutions which no professor
(unless they're a star pupil - in which case they wouldn't be asking)
would take as having been done by their selves.
(Or at least I hope not)

But yes, I would certainly be interested in the 'unsuccessful
attempt'.
(To the OP, do post your attempts, it does give more validity).


Cheers,

Jon.

== 6 of 6 ==
Date: Sat, Mar 13 2010 8:13 am
From: rurpy@yahoo.com


On Mar 13, 8:28 am, Patrick Maupin <pmau...@gmail.com> wrote:
> On Mar 13, 9:05 am, vsoler <vicente.so...@gmail.com> wrote:
>
> > Say that "m" is a tuple of 2-tuples
>
> > m=(('as',3), ('ab',5), (None, 1), ('as',None), ('as',6))
>
> > and I need to build a "d" dict where each key has an associated list
> > whose first element is the count, and the second is the sum. If a 2-
> > tuple contains a None value, it should be discarded.
>
> > The expected result is:
> > d={'as':[2, 9], 'ab': [1,5]}
>
> > How should I proceed? So far I have been unsuccessful. I have tried
> > with a "for" loop.
>
> Post your first try at a for loop, and people might be willing to
> point out problems, but this is such a basic for loop that it is
> unlikely that anybody is going to write your ENTIRE homework for you.

This is probably what you (OP) were trying to come up with?
[untested]

d = {}
for item in m:
key = m[0]; value = m[1]
if key is None or value is None: continue
if key not in dict:
d[key] = [value]
else:
d[key].append (value)

You can replace the
for item in m:
key = m[0]; value = m[1]
above with
for key, value in m:
which is a little nicer.

However, as other responses point out, when you want
to "accumulate" results in a dict, collections.defaultdict
should pop into your mind first.

==============================================================================
TOPIC: Use python and Jython together? (newbie)
http://groups.google.com/group/comp.lang.python/t/1ec71759062b2201?hl=en
==============================================================================

== 1 of 1 ==
Date: Sat, Mar 13 2010 7:10 am
From: Christian Heimes


Karjer Jdfjdf wrote:
> I'm pretty new at programming and want some advice on mixing Jython and Python.
>
> I want to use Jython to access some Java libraries, but I want to keep developing in normal Python. Some modules I use a lot are not available in Jython.
>
> The bulk of my programming is in Python but I want to use Java 2D libraries for graphical presentation of data generated in normal Python. Is it possible that I generate data in Python and then pass it through to a Jython program to visualise the data.

You can't mix Jython and Python in one program. But you can use other
means to create bindings for Java code. JCC
(http://pypi.python.org/pypi/JCC/2.5.1) is a very powerful code
generator for CPython.

Christian

==============================================================================
TOPIC: Ideas for creating processes
http://groups.google.com/group/comp.lang.python/t/104bababcbab6607?hl=en
==============================================================================

== 1 of 1 ==
Date: Sat, Mar 13 2010 7:41 am
From: Piet van Oostrum


>>>>> J <dreadpiratejeff@gmail.com> (J) wrote:

>J> And now I'm looking at subprocess and I can set shell=True and it will
>J> intrepret special characters like &

>J> So could I do something like this:

>J> for item in pathlist:
>J> subprocess.Popen('rsync command &', shell=True)

>J> and simply wait unti they are all done?

Using shell=True is often the wrong thing to do. And certainly just to
get a process to run in the background. subprocess will run them in the
background by default. Besides if you do it in the way you propose you
can't wait for them. You can only wait for the shell that starts the
rsync, but that will be finished almost immediately.

>>> import subprocess
>>> p = subprocess.Popen('sleep 1000 &', shell=True)
>>> p.wait()
0
>>>
The wait() returns immediately.
--
Piet van Oostrum <piet@vanoostrum.org>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]
Nu Fair Trade woonaccessoires op http://www.zylja.com

==============================================================================
TOPIC: Work at Home - Earn 50,000 Weekly Without Investment Its Not A Fake,
100% Earning Guarantee
http://groups.google.com/group/comp.lang.python/t/5065f5126e462427?hl=en
==============================================================================

== 1 of 1 ==
Date: Sat, Mar 13 2010 8:02 am
From: earner


Work at Home - Earn 50,000 Weekly Without Investment Its Not A Fake,
100% Earning Guarantee

For Register Click Here To Register Now - Start Earning Instantly!

http://www.cash-world.myfortuneincome.com
http://www.cash-world.myfortuneincome.com
http://www.cash-world.myfortuneincome.com
http://www.cash-world.myfortuneincome.com
http://www.cash-world.myfortuneincome.com
http://www.cash-world.myfortuneincome.com
http://www.cash-world.myfortuneincome.com

==============================================================================
TOPIC: wx error, I suspect my class
http://groups.google.com/group/comp.lang.python/t/6d211d7cdd75842d?hl=en
==============================================================================

== 1 of 1 ==
Date: Sat, Mar 13 2010 8:14 am
From: Alex Hall


Hello all,
I am trying to make a gui out of xrc and wxpython, but I think my
understanding of Python's class/method structure is causing problems.
The below code returns an error on the line
panel=xrc.XRCCTRL(mf, "dl")
The error goes back to wxPython itself and says "attribute error:
'none' type object has no attribute 'FindWindowById'"
Here is my complete code:

import wx
from wx import xrc

class myapp(wx.App):
def OnInit(self):
#load the xrc file
res=xrc.XmlResource('dictionary.xrc')

#load the frame containing everything else
mf=res.LoadFrame(None, "mainframe")

#assign all necessary controls to variables (text boxes and buttons)
for easier binding
#format: varName=xrc.XRCCTRL(parent, IDFromXRCFile)
panel=xrc.XRCCTRL(mf, "dl")
btn_go=xrc.XRCCTRL(panel, "btn_go")
btn_close=xrc.XRCCTRL(panel, "btn_close")

#now bind the gui controls to functions
mf.Bind(wx.EVT_BUTTON, close, id=xrc.XRCID("btn_close"))
mf.Show()

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate