Re: Sine wave?

2013-11-25 Thread zaindar4
On Thursday, December 26, 2002 9:50:14 AM UTC-5, Bengt Richter wrote:
> On Thu, 26 Dec 2002 12:38:56 -, cla...@lairds.com (Cameron Laird) wrote:
> 
> >In article , Bengt Richter  wrote:
> > .
> > .
> > .
> >>doing too many things. One could easily imagine an audio synth workbench
> >>(with the critical pieces in C).
> > .
> > .
> > .
> >You'll want to know about Snack http://wiki.tcl.tk/snack >.
> Thanks ;-) One more thing to bring to mind the general question:
> 
> Why are people killing each other when there is so much fun stuff
> to be had through friendly cooperation?
> 
> Regards,
> Bengt Richter

Hi Bengt,
i tried out your sinewave.py code and It works, is there a way that you can 
make it going horizontally instead of vertical? how does it work?
Thanks
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Excute script only from another file

2013-11-25 Thread Peter Otten
Himanshu Garg wrote:

> I want that a script should only be executed when it is called from
> another script and should not be directly executable through linux command
> line.
> 
> Like, I have two scripts "scrip1.py" and "script2.py"  and there is a line
> in "script1.py" to call "script2.py" as subprocess.call(["python",
> "script2.py"]).
> 
> Then this is should call script2 but I should not be able to directly call
> script2 as $python script2.py

Put the toplevel code into a function, i. e. change

#script2.py old
print "hello from script2"

to

# script2.py new

def f(): # you should pick a descriptive name instead of f
print "hello from script2"

and then import it from script1 and invoke the function:

# script1.py old
#...
subprocess.call("python", "script2.py")
#...

# script1.py new
import script1
#...
script.f()
#...



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


Re: calculate part of solid circle in 2D array

2013-11-25 Thread Robert Voigtländer
OK. Found a good one here:
http://www.daniweb.com/software-development/python/threads/321181/python-bresenham-circle-arc-algorithm

Now only filling is needed.
Any help is welcome ...

Thanks
Robert

Am Montag, 25. November 2013 08:26:19 UTC+1 schrieb Robert Voigtländer:
> Hi,
> 
> 
> 
> I wonder if someone can help me with a function I need for programming my 
> robot.
> 
> I want to update an 2D occupancy grid based on sonar data. The sonar “view 
> angle” is cone shaped. So I need to calculate all cells of a 30° slice of a 
> filled circle.
> 
> Something like this: 
> http://www.intechopen.com/source/html/37778/media/fig2.jpg
> 
> 
> 
> Using trigonometry is too expensive. I think something like Brenham’s circle 
> algorithm would be a good candidate.
> 
> But I need it filled (that would be doable for me I think) and I don’t need 
> the full circle but only a part of it.
> 
> 
> 
> I wonder if someone has a function like this lying around. If so I would be 
> glad to not have to reinvent the wheel 
> 
> 
> 
> Thanks and cheers
> 
> Robert
-- 
https://mail.python.org/mailman/listinfo/python-list


SetupTools

2013-11-25 Thread Chandru Rajendran
Hi all,

How can we set the target folder for the package in Setuptools?

Thanks & regards,
Chandru


 CAUTION - Disclaimer *
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely
for the use of the addressee(s). If you are not the intended recipient, please
notify the sender by e-mail and delete the original message. Further, you are 
not
to copy, disclose, or distribute this e-mail or its contents to any other 
person and
any such actions are unlawful. This e-mail may contain viruses. Infosys has 
taken
every reasonable precaution to minimize this risk, but is not liable for any 
damage
you may sustain as a result of any virus in this e-mail. You should carry out 
your
own virus checks before opening the e-mail or attachment. Infosys reserves the
right to monitor and review the content of all messages sent to or from this 
e-mail
address. Messages sent to or from this e-mail address may be stored on the
Infosys e-mail system.
***INFOSYS End of Disclaimer INFOSYS***
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: calculate part of solid circle in 2D array

2013-11-25 Thread Peter Otten
Robert Voigtländer wrote:

> OK. Found a good one here:
> http://www.daniweb.com/software-development/python/threads/321181/python-
bresenham-circle-arc-algorithm
> 
> Now only filling is needed.
> Any help is welcome ...

I think you shouldn't implement the algorithm directly. Rather look for a 
library that does it for you.

If you are using PIL like in the link you give above consider using the 
draw.arc() function directly:

http://effbot.org/imagingbook/imagedraw.htm

There is also cairographics where you draw a "path" on a "surface".

http://cairographics.org/documentation/pycairo/2/reference/context.html
http://cairographics.org/documentation/pycairo/2/reference/surfaces.html

Sorry, I can't help with the details.

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


Re: python for everyday tasks

2013-11-25 Thread wxjmfauth
Le samedi 23 novembre 2013 03:01:26 UTC+1, Steven D'Aprano a écrit :
> 
> 
> 
> * Python 3 (although not Python 2) is one of the few languages that get 
> 
> Unicode *right*. Strings in Python 3 are text, sequences of Unicode 
> 
> characters, not a thinly disguised blob of bytes. Starting with Python 
> 
> 3.3, Python does away with the difference between "narrow builds" (which 
> 
> save memory at the expense of correctness) and "wide builds" (which give 
> 
> correct Unicode behaviour at the cost of memory). Instead, Python 3.3 now 
> 
> has optimized strings that use only as much memory as needed. Pure ASCII 
> 
> strings will use 1 byte per character, while Unicode strings use 1, 2 or 
> 
> 4 bytes per character as needed. And it all happens transparently.
> 
> 


--



[topic beeing more of less closed]

Your paragraph is mixing different concepts.

When it comes to save memory, utf-8 is the choice. It
beats largely the FSR on the side of memory and on
the side of performances.

How and why? I suggest, you have a deeper understanding
of unicode.

May I recall, it is one of the coding scheme endorsed
by "Unicode.org" and it is intensively used. This is not
by chance.

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


Re: Excute script only from another file

2013-11-25 Thread Himanshu Garg
I was also thinking to add a sys argument when invoking script and check it.

My motive is "I will give scripts to somebody else and he should not run the 
script directly without running the parent script".

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


Re: Periodic execution with asyncio

2013-11-25 Thread Phil Connell
On Sat, Nov 23, 2013 at 09:30:29PM +0100, Tobias M. wrote:
> Now putting this into a PeriodicTask class that provides a similar interface
> like our callback version, I get:
> 
> 
> import asyncio
> 
> class PeriodicTask2(object):
> 
>  def __init__(self, func, interval):
>  self.func = func
>  self.interval = interval
>  self._loop = asyncio.get_event_loop()
> 
>  def start(self):
>  self.loop.run_until_complete(asyncio.Task(self._run()))
> 
> @asyncio.coroutine
>  def _run(self):
>  while True:
> yield from asyncio.sleep(self.interval)
> self.func()
> 
> 
> I don't know if I misunderstood anything, but as a user of this class I am
> not able to run two task simultaneously because start() will block. In the
> callback version I could instanciate two PeriodicTasks and run them both at
> the same time (after a call to loop.run_forever()), which is actually what I
> wanted to achieve with this class.

You need to separate out creating tasks from running the event loop.

Specifically, you should run the event loop in exactly one place, probably at
the top level of your script.


A toy example:

import asyncio

@asyncio.coroutine
def adder(*args, delay):
yield from asyncio.sleep(delay)
print(sum(args))

def main():
asyncio.Task(adder(1, 2, 3, delay=5))
asyncio.Task(adder(10, 20, delay=3))

loop = asyncio.get_event_loop()
loop.run_forever()

if __name__ == "__main__":
main()


$ ./python test.py
30
6


Note that run_forever() will block indefinitely (as the name suggests :). This
is generally what you'll want for a long-running server.

If you want do something more like:
- Spawn some tasks
- Run the event loop until they're done
- Exit

then you'll need to use loop.run_until_complete(asyncio.gather(*tasks))
instead.


HTH,
Phil

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


Re: Recursive generator for combinations of a multiset?

2013-11-25 Thread Oscar Benjamin
On 21 November 2013 13:01, John O'Hagan  wrote:
> In my use-case the first argument to multicombs is a tuple of words
> which may contain duplicates, and it produces all unique combinations
> of a certain length of those words, eg:
>
> list(multicombs(('cat', 'hat', 'in', 'the', 'the'), 3))
>
> [('cat', 'hat', 'in'), ('cat', 'hat', 'the'), ('cat', 'in', 'the'),
> ('cat', 'the', 'the'), ('hat', 'in', 'the'), ('hat', 'the', 'the'),
> ('in', 'the', 'the')]

I still don't understand what you're actually doing well enough to
know whether there is a better general approach to the problem. For
the specific thing you requested, here is a recursive multiset
combinations generator. Does it do what you wanted?

#!/usr/bin/env python

def multicombs(it, r):
words = []
last = None
for N, word in enumerate(it):
if word == last:
words[-1][1] += 1
else:
words.append([word, 1])
last = word
cumulative = 0
for n in range(len(words)-1, -1, -1):
words[n].append(cumulative)
cumulative += words[n][1]
return _multicombs((), words, r)

def _multicombs(prepend, words, r):
if r == 0:
yield prepend
return
(word, count, rem), *remaining = words
for k in range(max(r-rem, 0), min(count, r) + 1):
yield from _multicombs(prepend + (word,) * k, remaining, r-k)

expected = [
   ('cat', 'hat', 'in'),
   ('cat', 'hat', 'the'),
   ('cat', 'in', 'the'),
   ('cat', 'the', 'the'),
   ('hat', 'in', 'the'),
   ('hat', 'the', 'the'),
   ('in', 'the', 'the'),
]

output = list(multicombs(('cat', 'hat', 'in', 'the', 'the'), 3))

assert len(expected) == len(output)
assert set(expected) == set(output)  # The order is different


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


Re: Excute script only from another file

2013-11-25 Thread Dave Angel
On Mon, 25 Nov 2013 02:52:46 -0800 (PST), Himanshu Garg 
 wrote:
My motive is "I will give scripts to somebody else and he should 

not run the script directly without running the parent script".

Perhaps it should be a module,  not a script. Have it protect itself 
with the usual if __name__ == "__main__"


And of course it gets executed by an import and a call.

--
DaveA

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


Parallel Python x.y.A and x.y.B installations on a single Windows machine

2013-11-25 Thread Jurko Gospodnetić

  Hi all.

  I was wondering what is the best way to install multiple Python 
installations on a single Windows machine.


  Regular Windows installer works great as long as all your 
installations have a separate major.minor version identifier. However, 
if you want to have let's say 2.4.3 & 2.4.4 installed at the same time 
it does not seem to work.


  I have not been able to find any prepackaged Python installation or 
really any solution to this. Most of the advice seems to boil down to 
'do not use such versions together, use only the latest'.


  We would like to run automated tests on one of our projects (packaged 
as a Python library) with different Python versions, and since our code 
contains workarounds for several problems with specific Python patch 
versions, we'd really like to be able to run the tests with those 
specific versions and with as little fuss as possible.


  Looking at what the Python installer does, the only problematic part 
for working around this manually seems to be the registry entries under 
'Software\Python\PythonCore\M.m' where 'M.n' is the major.minor version 
identifier. If Python interpreter expects to always find its entries 
there, then I guess there is no way to do what we need without building 
customized Python executables. Is there a way to force a specific Python 
interpreter to not read in this information, read it from an .ini file 
or something similar?


  Many thanks.

  Best regards,
Jurko Gospodnetić

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


Re: Parallel Python x.y.A and x.y.B installations on a single Windows machine

2013-11-25 Thread Ned Batchelder
On Monday, November 25, 2013 7:32:30 AM UTC-5, Jurko Gospodnetić wrote:
> Hi all.
> 
>I was wondering what is the best way to install multiple Python 
> installations on a single Windows machine.
> 
>Regular Windows installer works great as long as all your 
> installations have a separate major.minor version identifier. However, 
> if you want to have let's say 2.4.3 & 2.4.4 installed at the same time 
> it does not seem to work.
> 
>I have not been able to find any prepackaged Python installation or 
> really any solution to this. Most of the advice seems to boil down to 
> 'do not use such versions together, use only the latest'.
> 
>We would like to run automated tests on one of our projects (packaged 
> as a Python library) with different Python versions, and since our code 
> contains workarounds for several problems with specific Python patch 
> versions, we'd really like to be able to run the tests with those 
> specific versions and with as little fuss as possible.
> 
>Looking at what the Python installer does, the only problematic part 
> for working around this manually seems to be the registry entries under 
> 'Software\Python\PythonCore\M.m' where 'M.n' is the major.minor version 
> identifier. If Python interpreter expects to always find its entries 
> there, then I guess there is no way to do what we need without building 
> customized Python executables. Is there a way to force a specific Python 
> interpreter to not read in this information, read it from an .ini file 
> or something similar?
> 
>Many thanks.
> 
>Best regards,
>  Jurko Gospodnetiďż˝

IIRC, Python itself doesn't read those registry entries, except when installing 
pre-compiled .msi or .exe kits.  Once you have Python installed, you can move 
the directory someplace else, then install another version of Python.

If you need to use many different Pythons of the same version, this script 
helps manage the registry: 
http://nedbatchelder.com/blog/201007/installing_python_packages_from_windows_installers_into.html

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


Re: Parallel Python x.y.A and x.y.B installations on a single Windows machine

2013-11-25 Thread Chris Angelico
On Mon, Nov 25, 2013 at 11:32 PM, Jurko Gospodnetić
 wrote:
> Most of the advice seems to boil down to 'do not use such versions together,
> use only the latest'.
>
>   We would like to run automated tests on one of our projects (packaged as a
> Python library) with different Python versions, and since our code contains
> workarounds for several problems with specific Python patch versions, we'd
> really like to be able to run the tests with those specific versions and
> with as little fuss as possible.

What this says to me is that you're doing something very unusual here
- most people won't be doing that. So maybe you need an unusual
solution.

Is it possible to set up virtualization to help you out? Create a
virtual machine in something like VirtualBox, then clone it for every
Python patch you want to support (you could have one VM that handles
all the .0 releases and another that handles all the .1 releases, or
you could have a separate VM for every Python you want to test). You
could then have a centralized master that each VM registers itself
with, and it feeds out jobs to them. Assuming your tests can be fully
automated, this could work out fairly efficiently - each VM has a
script that establishes a socket connection to the master, the master
hands out a job, the VMs run the test suite, the master collects up a
series of Pass/Fail reports. You could run everything on a single
physical computer, even.

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


Re: Parallel Python x.y.A and x.y.B installations on a single Windows machine

2013-11-25 Thread Albert-Jan Roskam

On Mon, 11/25/13, Jurko Gospodnetić  wrote:

 Subject: Parallel Python x.y.A and x.y.B installations on a single Windows 
machine
 To: python-list@python.org
 Date: Monday, November 25, 2013, 1:32 PM
 
   Hi all.
 
   I was wondering what is the best way to install
 multiple Python installations on a single Windows machine.
 
   Regular Windows installer works great as long as all
 your installations have a separate major.minor version
 identifier. However, if you want to have let's say 2.4.3
 & 2.4.4 installed at the same time it does not seem to
 work.
 
   I have not been able to find any prepackaged Python
 installation or really any solution to this. Most of the
 advice seems to boil down to 'do not use such versions
 together, use only the latest'.
 
   We would like to run automated tests on one of our
 projects (packaged as a Python library) with different
 Python versions, and since our code contains workarounds for
 several problems with specific Python patch versions, we'd
 really like to be able to run the tests with those specific
 versions and with as little fuss as possible.
 
   Looking at what the Python installer does, the only
 problematic part for working around this manually seems to
 be the registry entries under
 'Software\Python\PythonCore\M.m' where 'M.n' is the
 major.minor version identifier. If Python interpreter
 expects to always find its entries there, then I guess there
 is no way to do what we need without building customized
 Python executables. Is there a way to force a specific
 Python interpreter to not read in this information, read it
 from an .ini file or something similar?
 
HI Jurko,

Check out the following packages: virtualenv, virtualenvwrapper, tox
virtualenv + wrapper make it very easy to switch from one python version to 
another. Stricly speaking you don't need virtualenvwrapper, but it makes 
working with virtualenv a whole lot easier.Tox also uses virtualenv. You can 
configure it to sdist your package under different python versions. Also, you 
can make it run nosetests for each python version and/or implementation (pypy 
and jython are supported)

Albert-Jan 


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


Re: cx_Oracle throws: ImportError: DLL load failed: This application has failed to start ...

2013-11-25 Thread Albert-Jan Roskam

On Sun, 11/24/13, MRAB  wrote:

 Subject: Re: cx_Oracle throws: ImportError: DLL load failed: This application 
has failed to start ...
 To: python-list@python.org
 Date: Sunday, November 24, 2013, 7:17 PM
 
 On 24/11/2013 17:12, Ruben van den
 Berg wrote:
 > I'm on Windows XP SP3, Python 2.7.1. On running
 >
 > import cx_Oracle
 >
 > I got the error
 >
 > ImportError: DLL load failed: This application has
 failed to start because the application configuration is
 incorrect. Reinstalling the application may fix this
 problem.
 >
 > I then ran Dependency Walker on cx_Oracle.pyd. Its
 first complaint was about msvcr80.dll. However, this file is
 present in
 
C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.91_x-ww_0de56c07.
 (I believe it's part of the MS Visual Studio C++ 2008
 package which I installed.)
 >
 > I obviously uninstalled and reinstalled the cx_Oracle a
 couple of times but so far to no avail.
 >
 > Does anybody have a clue what to try next?
 >
 > For a screenshot of Dependency Walker, please see: 
 > https://dl.dropboxusercontent.com/u/116120595/dep_walker_orac.jpg
 >
 It looks like it's a path issue.
 
 You say that msvcr80.dll is in 
 
C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.91_x-ww_0de56c07,
 
 but is that folder listed as part of the search path?
 
 Have a look at the Windows' PATH environment variable.


===> Unlike in Linux with LD_LIBRARY_PATH, you can change PATH at runtime in 
Windows, e.g
import os, sys, ctypes
if sys.platform.startswith("win"):
os.environ["PATH"] += (os.pathsep + r"c:\your\new\path")
ctypes.WinDLL("msvcr80.dll")
 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python for everyday tasks

2013-11-25 Thread Mark Lawrence

On 25/11/2013 10:12, wxjmfa...@gmail.com wrote:

Le samedi 23 novembre 2013 03:01:26 UTC+1, Steven D'Aprano a écrit :


* Python 3 (although not Python 2) is one of the few languages that get

Unicode *right*. Strings in Python 3 are text, sequences of Unicode

characters, not a thinly disguised blob of bytes. Starting with Python

3.3, Python does away with the difference between "narrow builds" (which

save memory at the expense of correctness) and "wide builds" (which give

correct Unicode behaviour at the cost of memory). Instead, Python 3.3 now

has optimized strings that use only as much memory as needed. Pure ASCII

strings will use 1 byte per character, while Unicode strings use 1, 2 or

4 bytes per character as needed. And it all happens transparently.




[topic beeing more of less closed]

Your paragraph is mixing different concepts.

When it comes to save memory, utf-8 is the choice. It
beats largely the FSR on the side of memory and on
the side of performances.

How and why? I suggest, you have a deeper understanding
of unicode.

May I recall, it is one of the coding scheme endorsed
by "Unicode.org" and it is intensively used. This is not
by chance.

jmf



Yet more double spaced crap.

--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


Re: Parallel Python x.y.A and x.y.B installations on a single Windows machine

2013-11-25 Thread Jurko Gospodnetić

  Hi.

On 25.11.2013. 14:04, Chris Angelico wrote:

Is it possible to set up virtualization to help you out? Create a
virtual machine in something like VirtualBox, then clone it for every
Python patch you want to support (you could have one VM that handles
all the .0 releases and another that handles all the .1 releases, or
you could have a separate VM for every Python you want to test).
...


  Thank you for the suggestion.

  Yup, we could do that, but at first glance it really smells like an 
overkill. Not to mention the potential licensing issues with Windows and 
an unlimited number of Windows installations. :-)


  So far all tests seem to indicate that things work out fine if we 
install to some dummy target folder, copy the target folder to some 
version specific location & uninstall. That leaves us with a working 
Python folder sans the start menu and registry items, both of which we 
do not need for this. Everything I've played around with so far seems to 
use the correct Python data depending on the interpreter executable 
invoked, whether or not there is a regular Windows installation 
somewhere on the same machine.


  We can use the script suggested by Ned Batchelder to temporarily 
change the 'current installation' if needed for some external installer 
package to correctly recognize where to install its content.


  I'm still playing around with this, and will let you know how it goes.

  Thank you again for replying!

  Best regards,
Jurko Gospodnetić


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


Re: Parallel Python x.y.A and x.y.B installations on a single Windows machine

2013-11-25 Thread Chris Angelico
On Tue, Nov 26, 2013 at 12:42 AM, Jurko Gospodnetić
 wrote:
>   Yup, we could do that, but at first glance it really smells like an
> overkill. Not to mention the potential licensing issues with Windows and an
> unlimited number of Windows installations. :-)

Ah, heh... didn't think of that. When I spin up arbitrary numbers of
VMs, they're always Linux, so licensing doesn't come into it :)

>   So far all tests seem to indicate that things work out fine if we install
> to some dummy target folder, copy the target folder to some version specific
> location & uninstall. That leaves us with a working Python folder sans the
> start menu and registry items, both of which we do not need for this.
> Everything I've played around with so far seems to use the correct Python
> data depending on the interpreter executable invoked, whether or not there
> is a regular Windows installation somewhere on the same machine.

Okay! That sounds good. Underkill is better than overkill if you can
get away with it!

Good luck. You'll need it, if you're trying to support Python 2.4 and
all newer versions AND manage issues across patch releases...

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


Re: Parallel Python x.y.A and x.y.B installations on a single Windows machine

2013-11-25 Thread Jurko Gospodnetić

  Hi.

On 25.11.2013. 13:46, Ned Batchelder wrote:

IIRC, Python itself doesn't read those registry entries, except when installing 
pre-compiled .msi or .exe kits.  Once you have Python installed, you can move 
the directory someplace else, then install another version of Python.

If you need to use many different Pythons of the same version, this script 
helps manage the registry: 
http://nedbatchelder.com/blog/201007/installing_python_packages_from_windows_installers_into.html


  Thank you for the information!

  As I mentioned in another reply, so far I think we can use this 
script to temporarily change the 'current installation' if needed for 
some external installer package to correctly recognize where to install 
its content.


  If we do use it, I'll most likely modify it to first 
make a backup copy of the original registry key and use that later on to 
restore the original registry state instead of reconstructing its 
content to what the script assumes it should be.


  Best regards,
Jurko Gospodnetić


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


Re: Parallel Python x.y.A and x.y.B installations on a single Windows machine

2013-11-25 Thread Jurko Gospodnetić

  Hi.

On 25.11.2013. 14:20, Albert-Jan Roskam wrote:

Check out the following packages: virtualenv, virtualenvwrapper, tox
virtualenv + wrapper make it very easy to switch from one python
version to another. Stricly speaking you don't need
virtualenvwrapper, but it makes working with virtualenv a whole lot
easier.Tox also uses virtualenv. You can configure it to sdist your
package under different python versions. Also, you can make it run
nosetests for each python version and/or implementation (pypy and
jython are supported)


  I'll look into using virtualenv and possibly tox once I get into 
issues with mismatched installed Python package versions, but for now 
I'm dealing with installing different Python interpreter versions and, 
unless I'm overlooking something here, virtualenv does not help with 
that. :-(


  Thanks for the suggestion though, I'm definitely going to read up on 
those packages soon. :-)


  Best regards,
Jurko Gospodnetić


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


Re: calculate part of solid circle in 2D array

2013-11-25 Thread Robert Voigtländer
Thanks a lot for the links.

I don't need it to be drawn. I need the fields within the arc for some 
statistical calculations for an occupancy map.
So the target is a 2D array, not a picture.

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


Python application for rpm creation

2013-11-25 Thread Unix SA
Hello guys,

Probably not right forum but I thought I should get some suggestions.

I am looking for some tool written in python which can help users to create
rpm spec files and later help to build rpms, this will be for users who are
not aware of what spec file is and how to.create rpm.

Anyone knows such tool? It will be great if has gui.

Regards,
Dj
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Parallel Python x.y.A and x.y.B installations on a single Windows machine

2013-11-25 Thread Albert-Jan Roskam

On Mon, 11/25/13, Jurko Gospodnetić  wrote:

 Subject: Re: Parallel Python x.y.A and x.y.B installations on a single Windows 
machine
 To: python-list@python.org
 Date: Monday, November 25, 2013, 2:57 PM
 
   Hi.
 
 On 25.11.2013. 14:20, Albert-Jan Roskam wrote:
 > Check out the following packages: virtualenv,
 virtualenvwrapper, tox
 > virtualenv + wrapper make it very easy to switch from
 one python
 > version to another. Stricly speaking you don't need
 > virtualenvwrapper, but it makes working with virtualenv
 a whole lot
 > easier.Tox also uses virtualenv. You can configure it
 to sdist your
 > package under different python versions. Also, you can
 make it run
 > nosetests for each python version and/or implementation
 (pypy and
 > jython are supported)
 
   I'll look into using virtualenv and possibly tox once
 I get into issues with mismatched installed Python package
 versions, but for now I'm dealing with installing different
 Python interpreter versions and, unless I'm overlooking
 something here, virtualenv does not help with that. :-(
 
 > Are you sure? 
http://stackoverflow.com/questions/1534210/use-different-python-version-with-virtualenv

Below is a little terminal session.  I often switch between python 3.3 and 
python 2.7. My virtualenv for python 3.3 is called "python33". "workon" is a 
virtualenv wrapper command. And check out the envlist in tox.ini on 
http://tox.readthedocs.org/en/latest/example/basic.html

antonia@antonia-HP-2133 ~ $ workon python3.3
ERROR: Environment 'python3.3' does not exist. Create it with 'mkvirtualenv 
python3.3'.
antonia@antonia-HP-2133 ~ $ workon python33
(python33)antonia@antonia-HP-2133 ~ $ python
Python 3.3.2 (default, Sep  1 2013, 22:59:57) 
[GCC 4.7.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()
(python33)antonia@antonia-HP-2133 ~ $ deactivate
antonia@antonia-HP-2133 ~ $ python
Python 2.7.3 (default, Sep 26 2013, 16:38:10) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()



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


Re: Parallel Python x.y.A and x.y.B installations on a single Windows machine

2013-11-25 Thread Chris Angelico
On Tue, Nov 26, 2013 at 1:15 AM, Albert-Jan Roskam  wrote:
> Below is a little terminal session.  I often switch between python 3.3 and 
> python 2.7. My virtualenv for python 3.3 is called "python33". "workon" is a 
> virtualenv wrapper command. And check out the envlist in tox.ini on 
> http://tox.readthedocs.org/en/latest/example/basic.html

That's two different minor versions, though. Can you have 3.3.1 and
3.3.2 installed, by that method?

Incidentally, if this were on Linux, I would just build the different
versions in different directories, and then run them without
installing. But the OP seems to have a solution that works, and I
think it'll be the simplest.

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


Re: calculate part of solid circle in 2D array

2013-11-25 Thread Roy Smith
In article <1fc9a269-4847-4d29-a35e-5cf91731e...@googlegroups.com>,
 Robert Voigtländer  wrote:

> Thanks a lot for the links.
> 
> I don't need it to be drawn. I need the fields within the arc for some 
> statistical calculations for an occupancy map.
> So the target is a 2D array, not a picture.
> 
> Robert

If you go with one of the suggestions to use a graphics package to draw 
the arc, you can then take the resulting bitmap image and iterate over 
it to see which pixels are black and which are white.

But, I'm wondering about your comment that, "Using trigonometry is too 
expensive".  Trig is cheaper than you think, because it's all done down 
in the C libraries, and I wouldn't be surprised if it's not pushed all 
the way down to the hardware on most modern machines.  Compared to your 
Python application code, I suspect the amount of trig needed for this 
problem isn't going to be a major factor in timing.

Are you guessing that trig is too slow, or have you actually done some 
profiling to measure whether it is or not?

What's the resolution required?  Let's assume a 1k x 1k image with the 
sensor in the center and you need 1 degree angular resolution.  There's 
about 2200 pixels in each 1-degree sector.  You could pre-compute those 
and store 360 sets of 2200 pixels each (about 800k points total).  For 
any given 30 degree sector, just "or" together the 30 1-degree slices 
and you've got your set of pixels for that sector.

Will it be fast enough?  Beats me, but it's easy to test.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Savoynet] Festival

2013-11-25 Thread Chris Angelico
On Tue, Nov 26, 2013 at 1:39 AM, Musical Solutions
 wrote:
> Have a look at
> http://buxtonoperahouse.org.uk/146/Calendar?startFrom=1404172800
> and
> http://buxtonoperahouse.org.uk/146/Calendar?startFrom=1406851200
>

Huh, neat. Looks like that uses time_t to identify start times.

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


Re: python for everyday tasks

2013-11-25 Thread Michael Torrie
I only respond here, as unicode in general is an important concept that
the OP will to make sure his students understand in Python, and I don't
want you to dishonestly sow the seeds of uncertainty and doubt.

On 11/25/2013 03:12 AM, wxjmfa...@gmail.com wrote:
> Your paragraph is mixing different concepts.

On the contrary, it appears you are the one mixing the concepts, and
confusing a byte-encoding scheme with unicode.

In an ideal world, the programmer should not need to know or care about
what encoding scheme the language is using internally to store strings.
 And it does not matter whether the internal encoding scheme is endorsed
by the unicode commission or not, provided it can handle all the valid
unicode constructs.

A string is unicode.  Period.  Hence you must concern yourself with
encoding only when reading or writing a byte stream.

Inside the language itself, the encoding is irrelevant.  Ideally.  In
python 3.3+ anyway.  Of course reality is different in other languages
which is why programmers are used to worrying about things like exposing
surrogate pairs (as Javascript does), or having to tweak your algorithms
to deal with the fact that UTF-8 indexing is not O(1).  To claim that a
programmer has to concern himself with internal language encoding in
Python 3 is not only untrue, it's ingenuousness at best, given the OP's
mission.

> When it comes to save memory, utf-8 is the choice. It
> beats largely the FSR on the side of memory and on
> the side of performances.

So you would condemn everyone to use an O(n) encoding for a string when
FSR offers full unicode compliance that optimizes both speed and memory?

No, D'Aprano is correct.  Python 3.3+ indeed does unicode right.  It
offers O(1) slicing, is memory efficient, and never exposes things like
surrogate pairs.

> How and why? I suggest, you have a deeper understanding
> of unicode.

Indeed I'd say D'Aprano does have a deeper understanding of unicode.

> May I recall, it is one of the coding scheme endorsed
> by "Unicode.org" and it is intensively used. This is not
> by chance.

Yes, you keep saying this.  Have you encountered a real-world situation
where you are impacted by Python's FSR? You keep posting silly
benchmarks that prove nothing, and continue arguing, yet presumably you
are still using Python.  Why haven't you switched to Google Go or
another language that implements unicode strings in UTF-8?

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


Re: [Savoynet] Festival

2013-11-25 Thread Chris Angelico
On Tue, Nov 26, 2013 at 1:43 AM, Chris Angelico  wrote:
> On Tue, Nov 26, 2013 at 1:39 AM, Musical Solutions
>  wrote:
>> Have a look at
>> http://buxtonoperahouse.org.uk/146/Calendar?startFrom=1404172800
>> and
>> http://buxtonoperahouse.org.uk/146/Calendar?startFrom=1406851200
>>
>
> Huh, neat. Looks like that uses time_t to identify start times.

Pay no attention to the man behind the curtain...

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


Re: python for everyday tasks

2013-11-25 Thread Chris Angelico
On Tue, Nov 26, 2013 at 2:11 AM, Michael Torrie  wrote:
> Have you encountered a real-world situation
> where you are impacted by Python's FSR?

Python 3.3 was released back in September 2012, over a year ago. As
far as python-list can be aware, nobody - but nobody - has had any
problem with it except for jmf. I'm not entirely sure how this works -
it's fundamentally flawed for him, yet brilliant for everyone else.
Must be some sort of Bermuda Triangle effect around him, I think;
whatever it is, chaos scientists doubtless want to explore this.

Of course, a year isn't all that long, in computing. A 1GHz CPU core
can process about 3E16 instructions in that time. Maybe that's just
not sufficient evaluation time. Well, Pike's had the same
functionality - variable-width strings - since... well, I can't be
100% sure, but I found a reference to the size_shift field (1 for
8-bit, 2 for 16-bit, 3 for 32-bit) in a commit dated 1998, so I think
that's probably about when it was added. Somehow this concept has been
around and not breaking stuff for 15 years, and now it breaks all
jmf's code. There must be something very strange going on here, and I
really think it warrants investigation.

(Fifteen years. It's seventeen years since Unicode 2.0, when 16-bit
characters were outmoded. It's about time _every_ modern language
followed Python's and Pike's lead and got its Unicode support right.)

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


Re: Parallel Python x.y.A and x.y.B installations on a single Windows machine

2013-11-25 Thread Jurko Gospodnetić

  Hi.

On 25.11.2013. 15:15, Albert-Jan Roskam wrote:

  > Are you sure? 
http://stackoverflow.com/questions/1534210/use-different-python-version-with-virtualenv


  Yup, I'm pretty sure by now (based on reading the docs, not trying it 
out though).


  Virtualenv allows you to set up different environments, each of them 
having a separate Python folder structure and each possibly connected to 
a separate Python interpreter executable. However, it does not solve the 
problem of getting those separate Python interpreter executables 
installed in the first place, which is the problem I was attacking. :-)


  Still playing around with my multiple installations setup here. Will 
let you know how it goes...


  So far, one important thing I noticed is that you need to run all 
your installations 'for the current user only', or otherwise it moves at 
least one DLL file (python24.dll) into a Windows system folder and then 
the next installation deletes it from there, and overwrites it with its 
own. :-( But I can live with that... :-)


  Best regards,
Jurko Gospodnetić


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


Re: calculate part of solid circle in 2D array

2013-11-25 Thread Gene Heskett
On Monday 25 November 2013 10:18:29 Roy Smith did opine:

> In article <1fc9a269-4847-4d29-a35e-5cf91731e...@googlegroups.com>,
> 
>  Robert Voigtlنnder  wrote:
> > Thanks a lot for the links.
> > 
> > I don't need it to be drawn. I need the fields within the arc for some
> > statistical calculations for an occupancy map.
> > So the target is a 2D array, not a picture.
> > 
> > Robert
> 
> If you go with one of the suggestions to use a graphics package to draw
> the arc, you can then take the resulting bitmap image and iterate over
> it to see which pixels are black and which are white.
> 
> But, I'm wondering about your comment that, "Using trigonometry is too
> expensive".  Trig is cheaper than you think, because it's all done down
> in the C libraries, and I wouldn't be surprised if it's not pushed all
> the way down to the hardware on most modern machines.  Compared to your
> Python application code, I suspect the amount of trig needed for this
> problem isn't going to be a major factor in timing.
> 
> Are you guessing that trig is too slow, or have you actually done some
> profiling to measure whether it is or not?
> 
> What's the resolution required?  Let's assume a 1k x 1k image with the
> sensor in the center and you need 1 degree angular resolution.  There's
> about 2200 pixels in each 1-degree sector.  You could pre-compute those
> and store 360 sets of 2200 pixels each (about 800k points total).  For
> any given 30 degree sector, just "or" together the 30 1-degree slices
> and you've got your set of pixels for that sector.
> 
> Will it be fast enough?  Beats me, but it's easy to test.

A side comment here if I may.  Your 1 degree assumption is, generally 
speaking, an extremely coarse answer in terms of the accuracy needed, as we 
need accuracies a lot closer to an arc-second than to a whole degree in 
robotics.

To get an idea, assume a pick-n-place arm that has to retrieve the part 
from whatever method delivers it to within reach of the arm, the arms total 
joint to joint to joint length is 4 feet, and that the part is being 
delivered hot as in 700F, while the piece it will be installed on is fresh 
from contact with a block of dry ice.  So its a shrink fit, a one time 
assembly because once the temps equalize, the part will be shrunk into 
place so tightly that it can only be removed by a lathe.

So the accuracy needed to place this part properly at the start of the push 
to set it in place is .01mm, and the push into position must be done to a 
.01mm accuracy before the parts freeze together.

I know, this is a bit like asking if that persimmon branch will hold 2 
opossums, but what is the accuracy needed in arc seconds per joint 
(counting the arms pivot joint, and an articulated wrist for part 
orientation, makes at least 5 joints, to pull this motion off every 15 
seconds on some GM part assembly line at Delphi?

Real world problem guys.  My own experience with machine vision says that 
without cameras and video processing running at 1000x the speeds of what I 
can buy on fleabay, its way to slow (see camview-emc for an example) to 
actually be used in a production line environment, they don't have time for 
the arm to stop just short of where its going, take a closeup pix & wait 
3-5 seconds for the video to be processed, and then apply the corrective 
moves to 'get it right'.

This isn't even worth a reply, its even off-topic, but when an OP posits a 
problem, he should posit it in terms of his real world targets, as should 
the answers proposed.  The correct answer may well help your parent company 
sell Delphi some new machines at 5 mil/copy.

Cheers, Gene
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)

Wedding is destiny, and hanging likewise.
-- John Heywood
A pen in the hand of this president is far more
dangerous than 200 million guns in the hands of
 law-abiding citizens.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python for everyday tasks

2013-11-25 Thread wxjmfauth
Le lundi 25 novembre 2013 16:11:22 UTC+1, Michael Torrie a écrit :
> I only respond here, as unicode in general is an important concept that
> 
> the OP will to make sure his students understand in Python, and I don't
> 
> want you to dishonestly sow the seeds of uncertainty and doubt.
> 
> 
> 
> On 11/25/2013 03:12 AM, wxjmfa...@gmail.com wrote:
> 
> > Your paragraph is mixing different concepts.
> 
> 
> 
> On the contrary, it appears you are the one mixing the concepts, and
> 
> confusing a byte-encoding scheme with unicode.
> 
> 
> 
> In an ideal world, the programmer should not need to know or care about
> 
> what encoding scheme the language is using internally to store strings.
> 
>  And it does not matter whether the internal encoding scheme is endorsed
> 
> by the unicode commission or not, provided it can handle all the valid
> 
> unicode constructs.
> 
> 
> 
> A string is unicode.  Period.  Hence you must concern yourself with
> 
> encoding only when reading or writing a byte stream.
> 
> 
> 
> Inside the language itself, the encoding is irrelevant.  Ideally.  In
> 
> python 3.3+ anyway.  Of course reality is different in other languages
> 
> which is why programmers are used to worrying about things like exposing
> 
> surrogate pairs (as Javascript does), or having to tweak your algorithms
> 
> to deal with the fact that UTF-8 indexing is not O(1).  To claim that a
> 
> programmer has to concern himself with internal language encoding in
> 
> Python 3 is not only untrue, it's ingenuousness at best, given the OP's
> 
> mission.
> 
> 
> 
> > When it comes to save memory, utf-8 is the choice. It
> 
> > beats largely the FSR on the side of memory and on
> 
> > the side of performances.
> 
> 
> 
> So you would condemn everyone to use an O(n) encoding for a string when
> 
> FSR offers full unicode compliance that optimizes both speed and memory?
> 
> 
> 
> No, D'Aprano is correct.  Python 3.3+ indeed does unicode right.  It
> 
> offers O(1) slicing, is memory efficient, and never exposes things like
> 
> surrogate pairs.
> 
> 
> 
> > How and why? I suggest, you have a deeper understanding
> 
> > of unicode.
> 
> 
> 
> Indeed I'd say D'Aprano does have a deeper understanding of unicode.
> 
> 
> 
> > May I recall, it is one of the coding scheme endorsed
> 
> > by "Unicode.org" and it is intensively used. This is not
> 
> > by chance.
> 
> 
> 
> Yes, you keep saying this.  Have you encountered a real-world situation
> 
> where you are impacted by Python's FSR? You keep posting silly
> 
> benchmarks that prove nothing, and continue arguing, yet presumably you
> 
> are still using Python.  Why haven't you switched to Google Go or
> 
> another language that implements unicode strings in UTF-8?

--

Everybody has the right to have an opinion. Understand
I respect Steven's opinion.

---

I'm aware of the utf-8 indexing "effect" (it is in fact the
answer I expected), that's why I proposed to dive a little
bit more in "unicode".

Now something else.
I'm practically no more programming in the sense creating
applications, but mainly interested in unicode. I "toyed" with
many tools, C#, go, ruby2 and my favorite, the TeX unicode engines.
I just happen I have a large experience with Python and I'm finding
this FSR fascinating.

jmf

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


Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !

2013-11-25 Thread Grant Edwards
On 2013-11-23, Steven D'Aprano  wrote:
> On Sat, 23 Nov 2013 01:55:44 +, Denis McMahon wrote:
>
>> On Fri, 22 Nov 2013 18:22:29 +0530, Bharath Kummar wrote:
>
>>> Could you PLEASE provide me with the codes (codes only for the asked
>>> queries) ?
>> 
>> The codes are:
>> 
>> 1) 7373a28109a7c4473a475b2137aa92d5
>> 2) f2fae9a4ad5ded75e4d8ac34b90d5c9c
>> 3) 935544894ca6ad7239e0df048b9ec3e5
>> 4) b1bc9942d029a4a67e4b368a1ff8d883
>> 
>> Please contact your local government eavesdropping agency for assistance
>> on decoding the codes.
>
> I'm not an expert on Indian English, but I understand that in that 
> dialect it is grammatically correct to say "the codes", just as in UK and 
> US English it is grammatically correct to say "the programs".

I think Dennis was taking aim at the OP's request that somebody do his
homework assignment for him rather than at his incorrect (in US
"standard" English) use of the mass noun "code".

Mass nouns seem to be a common tripping point for people learning
English as a second language (and for some with English as their first
language). I'm not sure if that's because their first language doesn't
have something that corresponds to countable vs. mass nouns, or if
it's just the usual problem of English being so random and irregular
that it can only be learned easily by a toddler.

-- 
Grant Edwards   grant.b.edwardsYow! I like the way ONLY
  at   their mouths move ...  They
  gmail.comlook like DYING OYSTERS
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !

2013-11-25 Thread Grant Edwards
On 2013-11-23, Dave Angel  wrote:

> Try posting in text, as some of us see nothing in your message. This 
> is a text newsgroup, not html.
>
> Also make a subject line that summarizes your issue, not the urgency.

An exclamation mark is a yellow flag, and three should definitly route
a message to /dev/null.

-- 
Grant Edwards   grant.b.edwardsYow! Like I always say
  at   -- nothing can beat
  gmail.comthe BRATWURST here in
   DUSSELDORF!!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !

2013-11-25 Thread Steven D'Aprano
On Mon, 25 Nov 2013 16:25:57 +, Grant Edwards wrote:

> On 2013-11-23, Dave Angel  wrote:
> 
>> Try posting in text, as some of us see nothing in your message. This is
>> a text newsgroup, not html.
>>
>> Also make a subject line that summarizes your issue, not the urgency.
> 
> An exclamation mark is a yellow flag, and three should definitly route a
> message to /dev/null.


"What sort of person," said Salzella patiently, "sits down and writes a 
maniacal laugh? And all those exclamation marks, you notice? Five? A sure 
sign of someone who wears his underpants on his head."

-- (Terry Pratchett, Maskerade)



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


Re: Parallel Python x.y.A and x.y.B installations on a single Windows machine

2013-11-25 Thread Terry Reedy

On 11/25/2013 8:42 AM, Jurko Gospodnetić wrote:


   So far all tests seem to indicate that things work out fine if we
install to some dummy target folder, copy the target folder to some
version specific location & uninstall.


If the dummy folder had 3.3.0, you should not need to uninstall to 
install 3.3.1 on top of it. But it is easy and probably safest.



That leaves us with a working
Python folder sans the start menu and registry items, both of which we
do not need for this. Everything I've played around with so far seems to
use the correct Python data depending on the interpreter executable
invoked, whether or not there is a regular Windows installation
somewhere on the same machine.


Just a reminder: you can run one file or set of files with multiple 
Pythons by putting 'project.pth' containing the same 'path-to-project' 
in the Lib/site-packages of each Python directory. I do this to test one 
file with 2.7 and 3.3 (and just added 3.4) without copying the file.


--
Terry Jan Reedy


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


Re: Python application for rpm creation

2013-11-25 Thread Terry Reedy

On 11/25/2013 9:17 AM, Unix SA wrote:


Probably not right forum but I thought I should get some suggestions.

I am looking for some tool written in python which can help users to
create rpm spec files and later help to build rpms, this will be for
users who are not aware of what spec file is and how to.create rpm.

Anyone knows such tool? It will be great if has gui.


What have you done already and why has it not worked?

The distutils package has bdist-rpm command. Web search will give you more.

--
Terry Jan Reedy

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


Re: Parallel Python x.y.A and x.y.B installations on a single Windows machine

2013-11-25 Thread Jurko Gospodnetić

  Hi.

On 25.11.2013. 17:38, Terry Reedy wrote:

   So far all tests seem to indicate that things work out fine if we
install to some dummy target folder, copy the target folder to some
version specific location & uninstall.


If the dummy folder had 3.3.0, you should not need to uninstall to
install 3.3.1 on top of it. But it is easy and probably safest.


  Without the uninstall step you get stuck with invalid registry and 
start menu items refering to an invalid path until you install another 
matching major.minor.X version.




Just a reminder: you can run one file or set of files with multiple
Pythons by putting 'project.pth' containing the same 'path-to-project'
in the Lib/site-packages of each Python directory. I do this to test one
file with 2.7 and 3.3 (and just added 3.4) without copying the file.


  Thanks for the tip. That might come in useful. At the moment I just 
run the pytest framework using different python interpreters, without 
having to install the package at all (possibly first running 'setup.py 
build' to get the sources converted to Python 3 format).


  Best regards,
Jurko Gospodnetić


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


Re: Python application for rpm creation

2013-11-25 Thread Alister
On Mon, 25 Nov 2013 19:47:44 +0530, Unix SA wrote:

> Hello guys,
> 
> Probably not right forum but I thought I should get some suggestions.
> 
> I am looking for some tool written in python which can help users to
> create rpm spec files and later help to build rpms, this will be for
> users who are not aware of what spec file is and how to.create rpm.
> 
> Anyone knows such tool? It will be great if has gui.

Dist utils can write an RPM file if you have a correctly configured 
setup.py

No Gui, but it should be possible to write one.



-- 
If I can have honesty, it's easier to overlook mistakes.
-- Kirk, "Space Seed", stardate 3141.9
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: SetupTools

2013-11-25 Thread Chris “Kwpolska” Warrick
On Mon, Nov 25, 2013 at 9:35 AM, Chandru Rajendran
 wrote:
>
> Hi all,
> How can we set the target folder for the package in Setuptools?

The answer likely is *you are not allowed to do this*.  It’s up to the
user to set it.

Unless you are the user, and want to have the packages you install go
to a place desired by you, then the --prefix parameter may be of help
(although you are better off by using a virtualenv which makes it
unnecessary)

>  CAUTION - Disclaimer *
> [snip]
> ***INFOSYS End of Disclaimer INFOSYS***


Tell your legal department that such notices have no legal power
whatsoever and are just a waste of everyone’s bandwidth, time and the
like.

-- 
Chris “Kwpolska” Warrick 
PGP: 5EAAEA16
stop html mail | always bottom-post | only UTF-8 makes sense
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Ann] pyBug - Python Belgian User Group

2013-11-25 Thread hendrikxi
Dear Jonas
I  need someone who knows to write Phyton programmes.
The application is a controller for performing tests.
Can you propose names or yourself?
Best regards
Ivan Hendrikx
ESTH
Lange Schouwenstraat 1B
3520 Zonhoven
tel 0475 301978
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python application for rpm creation

2013-11-25 Thread Unix SA
Hey,

sorry, this is something new for me and i am looking if something is
already developed, btw i am not looking for python module creation packages
.. what i am looking is for ex .. my users have their code written in C or
Java or any other lang and they want to package it in Linux RPM and for
that is that any tool which can help to create SPEC file ?//

i am aware of tito.. which can help me for building RPM.. but before that i
am looking for tool to create spec file.

Regards,
DJ


On Mon, Nov 25, 2013 at 10:12 PM, Terry Reedy  wrote:

> On 11/25/2013 9:17 AM, Unix SA wrote:
>
>  Probably not right forum but I thought I should get some suggestions.
>>
>> I am looking for some tool written in python which can help users to
>> create rpm spec files and later help to build rpms, this will be for
>> users who are not aware of what spec file is and how to.create rpm.
>>
>> Anyone knows such tool? It will be great if has gui.
>>
>
> What have you done already and why has it not worked?
>
> The distutils package has bdist-rpm command. Web search will give you more.
>
> --
> Terry Jan Reedy
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python application for rpm creation

2013-11-25 Thread Andrew Heagle
On Mon, Nov 25, 2013 at 9:17 AM, Unix SA  wrote:

> Hello guys,
>
> Probably not right forum but I thought I should get some suggestions.
>
> I am looking for some tool written in python which can help users to
> create rpm spec files and later help to build rpms, this will be for users
> who are not aware of what spec file is and how to.create rpm.
>
> Anyone knows such tool? It will be great if has gui.
>
> Regards,
> Dj
>
Sounds to me more like he is looking to package some other in house
software, as opposed to packaging python specific libraries, etc...

I think you can just provide a blank spec file for them to 'fill in the
blanks', however, using a GUI would be tricky since some parts of the spec
file you typically wouldn't be able to complete until after attempting to
build a few times (eg, %file section).

Doing an apt-cache search on my Ubuntu desktop results with a project,
Spectacle, coincidentally written in Python. (I haven't really looked into
it):
http://meego.gitorious.org/meego-developer-tools/spectacle

When you have your spec files made, I'd recommend using this service to
build your RPMS: https://build.opensuse.org/


Regards,
Andrew
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: SetupTools

2013-11-25 Thread Grant Edwards
On 2013-11-25, Chris ???Kwpolska??? Warrick  wrote:

> Tell your legal department that 
[...]

Ha! good one!

In my experience, corporate legal departments have an "ask only" API. 

All attempts to tell them things will be ignored.

-- 
Grant Edwards   grant.b.edwardsYow! Will the third world
  at   war keep "Bosom Buddies"
  gmail.comoff the air?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !

2013-11-25 Thread Rick Johnson
On Saturday, November 23, 2013 7:38:47 PM UTC-6, Steven D'Aprano wrote:
> Where do you, an American,

What the hell makes you believe I'm an American? Because i
speak fluent English? Because i embrace capitalism? Because
i wish to be free of tyranny? Well, if that's all it takes
to be an American, then count me in!

America.append("RickJohnson")

> get off telling others that their regional variety of
> English is incorrect?

Because with the ALREADY excessive polysemous nature of the
English language, why would we want to PURPOSELY inject more
inconsistency?.. especially when the sole purpose of the
change is driven by selfishness?

Do you remember your thread titled: "The narcissism of small
code differences"? Do you remember how the author warned
against the dangers of re-writing old code for fear of
enduring lengthy de-bugging trials?

Okay, with that synopsis in mind, now you want us to believe
that injecting polysemy into the English language JUST for
the mere PRIDE of "regional groups" is not:

  destructive?
  or at least harmful?
  or at minimum, non-productive?

> Sod off and take your despicable little Randian pseudo-
> philosophy with you.

Yes because women couldn't *possibly* be "legitimate"
philosophers -- is that correct? Or is your chauvinist anger
towards Ayn merely a mask to disguise the *real* source of
hatred: the defection of a fellow "comrade" to the
capitalist system?

How dare people allow themselves to be free! 

HOW DARE THEY!

...who's the fascist now?
-- 
https://mail.python.org/mailman/listinfo/python-list


How to determine whether client and server are on the same host

2013-11-25 Thread Malte Forkel
Hi,

I have a Python application that communicates with a server via telnet.
Host and port of the server are supplied by the user when the
application is started.

How can I determine from within the application whether the server's
host actually is the local host? (In that case I could implement an
operation not available in the telnet-based protocol by directly
accessing the local filesystem.)

Sounds like there should be an obvious solution. Unfortunately, I
haven't found it yet :-)

Malte

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


Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !

2013-11-25 Thread Antoon Pardon
Op 23-11-13 03:18, Steven D'Aprano schreef:
> On Sat, 23 Nov 2013 01:55:44 +, Denis McMahon wrote:
> 
>> On Fri, 22 Nov 2013 18:22:29 +0530, Bharath Kummar wrote:
> 
>>> Could you PLEASE provide me with the codes (codes only for the asked
>>> queries) ?
>>
>> The codes are:
>>
>> 1) 7373a28109a7c4473a475b2137aa92d5
>> 2) f2fae9a4ad5ded75e4d8ac34b90d5c9c
>> 3) 935544894ca6ad7239e0df048b9ec3e5
>> 4) b1bc9942d029a4a67e4b368a1ff8d883
>>
>> Please contact your local government eavesdropping agency for assistance
>> on decoding the codes.
> 
> I'm not an expert on Indian English, but I understand that in that 
> dialect it is grammatically correct to say "the codes", just as in UK and 
> US English it is grammatically correct to say "the programs".
> 
> In other words, in UK/US English, "code" in the sense of programming code 
> is an uncountable noun, like "rice" or "air", while in Indian English it 
> is a countable noun like cats or programs. We have to say "give me two 
> samples of code", or perhaps "two code samples", while an Indian speaker 
> might say "give me two codes".
> 
> As this is an international forum, it behoves us all to make allowances 
> for slight difference in dialect.

I don't see how that follows. I would say on the contrary. This being
an international forum people should try to reframe from burdening
lots of other people with expressions most people will not understand
or even misunderstand.

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


Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !

2013-11-25 Thread Joel Goldstick
>> I'm not an expert on Indian English, but I understand that in that
>> dialect it is grammatically correct to say "the codes", just as in UK and
>> US English it is grammatically correct to say "the programs".
>>
>> In other words, in UK/US English, "code" in the sense of programming code
>> is an uncountable noun, like "rice" or "air", while in Indian English it
>> is a countable noun like cats or programs. We have to say "give me two
>> samples of code", or perhaps "two code samples", while an Indian speaker
>> might say "give me two codes".
>>
>> As this is an international forum, it behoves us all to make allowances
>> for slight difference in dialect.
>
> I don't see how that follows. I would say on the contrary. This being
> an international forum people should try to reframe from burdening
> lots of other people with expressions most people will not understand
> or even misunderstand.
>
> --
> Antoon Pardon
> --
> https://mail.python.org/mailman/listinfo/python-list


I see the different idioms as kind of interesting, and funny
sometimes, but I don't think they pose a big barrier.  Mostly, people
don't provide OS or python version, or explain what they done and what
happens.  That makes it harder to respond than figuring out how
different people around the world say stuff.  I'm from US and I have
done lots of phone calls with Indian developers.  To me it sounds
strange to talk about codes, but I totally understand what they mean.
A bigger problem I have had is in understanding accents during multi
person phone calls with people from other countries.   Different
'English' speakers actually speak more differently than we write. At
least here we can read the words, even if they are different.
-- 
Joel Goldstick
http://joelgoldstick.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !

2013-11-25 Thread Ned Batchelder
On Monday, November 25, 2013 2:32:12 PM UTC-5, Rick Johnson wrote:
> On Saturday, November 23, 2013 7:38:47 PM UTC-6, Steven D'Aprano wrote:
> > Where do you, an American,
> 
> What the hell makes you believe I'm an American? Because i
> speak fluent English? Because i embrace capitalism? Because
> i wish to be free of tyranny? Well, if that's all it takes
> to be an American, then count me in!
> 
> America.append("RickJohnson")
> 
> > get off telling others that their regional variety of
> > English is incorrect?
> 
> Because with the ALREADY excessive polysemous nature of the
> English language, why would we want to PURPOSELY inject more
> inconsistency?.. especially when the sole purpose of the
> change is driven by selfishness?
> 
> Do you remember your thread titled: "The narcissism of small
> code differences"? Do you remember how the author warned
> against the dangers of re-writing old code for fear of
> enduring lengthy de-bugging trials?
> 
> Okay, with that synopsis in mind, now you want us to believe
> that injecting polysemy into the English language JUST for
> the mere PRIDE of "regional groups" is not:
> 
>   destructive?
>   or at least harmful?
>   or at minimum, non-productive?
> 
> > Sod off and take your despicable little Randian pseudo-
> > philosophy with you.
> 
> Yes because women couldn't *possibly* be "legitimate"
> philosophers -- is that correct? Or is your chauvinist anger
> towards Ayn merely a mask to disguise the *real* source of
> hatred: the defection of a fellow "comrade" to the
> capitalist system?
> 
> How dare people allow themselves to be free! 
> 
> HOW DARE THEY!
> 
> ...who's the fascist now?

Rick, I've never understood how much your rants are tongue-in-cheek, or 
intended to amuse, and how much they accurately represent your philosophy and 
mindset.  Most of your rants had to do with programming at least.  Let's please 
avoid veering off into rants about language and philosophy now.

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


Re: cx_Oracle throws: ImportError: DLL load failed: This application has failed to start ...

2013-11-25 Thread Ruben van den Berg
Thx for all the suggestions! 

I hope this doesn't come as a disappointment but it seems the final solution 
was to install version 12 (instead of 11) of Oracle's instantclient and to 
include the inner folder (holding OCI.DLL and related files) to "Path" and 
"ORACLE_HOME".

I haven't the slightest clue why version 11 just - wouldn't - run but due to 
backward compatibility it seems a stressful weekend got a happy ending anyway.

Op maandag 25 november 2013 11:38:39 UTC+1 schreef Albert-Jan Roskam:
> 
> 
> On Sun, 11/24/13, MRAB  wrote:
> 
> 
> 
>  Subject: Re: cx_Oracle throws: ImportError: DLL load failed: This 
> application has failed to start ...
> 
>  To: python-list@python.org
> 
>  Date: Sunday, November 24, 2013, 7:17 PM
> 
>  
> 
>  On 24/11/2013 17:12, Ruben van den
> 
>  Berg wrote:
> 
>  > I'm on Windows XP SP3, Python 2.7.1. On running
> 
>  >
> 
>  > import cx_Oracle
> 
>  >
> 
>  > I got the error
> 
>  >
> 
>  > ImportError: DLL load failed: This application has
> 
>  failed to start because the application configuration is
> 
>  incorrect. Reinstalling the application may fix this
> 
>  problem.
> 
>  >
> 
>  > I then ran Dependency Walker on cx_Oracle.pyd. Its
> 
>  first complaint was about msvcr80.dll. However, this file is
> 
>  present in
> 
>  
> C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.91_x-ww_0de56c07.
> 
>  (I believe it's part of the MS Visual Studio C++ 2008
> 
>  package which I installed.)
> 
>  >
> 
>  > I obviously uninstalled and reinstalled the cx_Oracle a
> 
>  couple of times but so far to no avail.
> 
>  >
> 
>  > Does anybody have a clue what to try next?
> 
>  >
> 
>  > For a screenshot of Dependency Walker, please see: 
> https://dl.dropboxusercontent.com/u/116120595/dep_walker_orac.jpg
> 
>  >
> 
>  It looks like it's a path issue.
> 
>  
> 
>  You say that msvcr80.dll is in 
> 
>  
> C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.91_x-ww_0de56c07,
> 
>  
> 
>  but is that folder listed as part of the search path?
> 
>  
> 
>  Have a look at the Windows' PATH environment variable.
> 
> 
> 
> 
> 
> ===> Unlike in Linux with LD_LIBRARY_PATH, you can change PATH at runtime in 
> Windows, e.g
> 
> import os, sys, ctypes
> 
> if sys.platform.startswith("win"):
> 
> os.environ["PATH"] += (os.pathsep + r"c:\your\new\path")
> 
> ctypes.WinDLL("msvcr80.dll")

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


Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !

2013-11-25 Thread Ethan Furman

On 11/25/2013 11:53 AM, Antoon Pardon wrote:

Op 23-11-13 03:18, Steven D'Aprano schreef:


As this is an international forum, it behoves us all to make allowances
for slight difference in dialect.


I don't see how that follows. I would say on the contrary. This being
an international forum people should try to reframe from burdening
lots of other people with expressions most people will not understand
or even misunderstand.


So we can assume you've made a comprehensive study of the different varieties of English and created a compendium of 
which words and/or phrases can be easily misunderstood?  Please share that with us, it would be quite helpful.


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


Getting the Appdata Directory with Python and PEP?

2013-11-25 Thread Eamonn Rea
I've heard that there is a library that allows you to get the appdata directory 
for a given OS, but I'd like to do it myself, as a learning experience.

Is there a built in way to get a users Appdata Directory? For example on OS X 
it's in '~/Library//Application Support/'. I can get the OS just fine 
(sys.platform and then storing it in my own way; example: darwin = OS X, just 
for my own readability), and I can get the home directory just fine 
(expanduser), but I have no idea how to get the appdata directory.

One way I could think of doing it would be to just detect the os and join the 
string on like so (completely untested, but an idea);

if os == 'OS X':
appdata_dir = os.path.join(home_dir, '/Application Support/')

But then that arises the problem of cross platform compatibility.

So is here a good, cross platform solution to this problem?

Also, what is PEP, PEP8, etc? Is it like the Python programming layout 
conventions? Is there more to it than that?

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


Consumer level eye tracking - easy activation of virtual buttons without touchscreen - wxpython for buttons, & AutoIt for macros behind buttons?

2013-11-25 Thread Jeff Kang
(First off, sorry in advance, as I’m not sure if this is the right place to 
post my inquiry).

*Consumer level eye tracking - easy activation of virtual buttons without 
touchscreen*

After using Autohotkey for remapping, I soon didn't have enough keyboard 
buttons to attach macros and lines of code to them, so I'd have to make new 
scripts that use the same button. After more scripts, it can be easy to forget 
which button does what.

I have a repetitive strain injury of tendinosis (chronic tendinitis), so I was 
following a couple of eye tracking companies that were planning to launch 
cheap, mass-market products. One company has just begun preorders. 

You can now optionally take away your hands for moving the mouse cursor. 
Instead, stare at a target on-screen button, and using a keyboard button to 
click, you can instantly invoke custom virtual buttons that have your macros 
and commands that are attached to them. Quick activation of on-screen shortcut 
tiles without a touchscreen is now more feasible. You could pretty much design 
the buttons to look however you want. Customizable, virtual buttons are 
infinitely more productive than static physical keys.

e.g. I remapped F1 to launch a google search on whatever is on the clipboard:
F1::Run http://www.google.com/search?hl=en&safe=off&q=%Clipboard% .

With another script, F1 could execute something completely different. And 
within that script, depending on the context, such as what program is currently 
running, or what window is in focus, the use of F1 could change again; it can 
get confusing.

It would be more intuitive to look at a virtual button that is actually 
labeled, "Clipboard Google Search", and then tap my activation key.

*wxpython for buttons, & AutoIt for macros behind buttons?*

Is it possible to use a GUI tool like wxpython to design the buttons, and then 
use a scripting language like AutoIt, AutoHotkey, AutoKey, or Sikuli to run the 
scripts and functions?

I found a blog post called "Importing AutoIt into Python". Here is some of what 
is mentioned: 
“It is possible to import all of AutoIt's functions from a required .dll file 
into python.  Then I can use python to code and when I need an AutoIt function 
I can just call the function. 

First you must tell Python that you are going to be using an external file, you 
do this by using import.

You can now call AutoIt functions using autoit.TheFunctionName()”

There is also some information in a StackOverflow post called "Calling AutoIt 
Functions in Python" 
(http://stackoverflow.com/questions/3301561/calling-autoit-functions-in-python):

“In order to call Autoit functions from python using Autoit's COM interface, 
there are few prerequisites:

An installation of python with the appropriate python for windows extentions 
(pywin32)
An full installation of Autoit. (It is possible to only install the COM 
portion, but it is more involved than a full installation.)
In order to call autoit functions from python, add the following code:

import win32com.client
autoit = win32com.client.Dispatch("AutoItX3.Control")

You can now call autoit functions with the autoit variable.

autoit.Run("NotePad.exe")
autoit.ControlClick(WINDOW, "", "[CLASSNN:TTreeView1]", "left", 1, 53, 41)
“

I'm not a programmer; just beginning. Are wxpython and AutoIt (AutoItX?) a 
reasonably good direction for getting something like what I am describing?

Thanks for any info.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Getting the Appdata Directory with Python and PEP?

2013-11-25 Thread Andrew Berg
On 2013.11.25 14:48, Eamonn Rea wrote:
> I've heard that there is a library that allows you to get the appdata 
> directory for a given OS, but I'd like to do it myself, as a learning 
> experience.
> 
> Is there a built in way to get a users Appdata Directory? For example on OS X 
> it's in '~/Library//Application Support/'. I can get the OS just fine 
> (sys.platform and then storing it in my own way; example: darwin = OS X, just 
> for my own readability), and I can get the home directory just fine 
> (expanduser), but I have no idea how to get the appdata directory.
> 
> One way I could think of doing it would be to just detect the os and join the 
> string on like so (completely untested, but an idea);
> 
> if os == 'OS X':
> appdata_dir = os.path.join(home_dir, '/Application Support/')
> 
> But then that arises the problem of cross platform compatibility.
> 
> So is here a good, cross platform solution to this problem?
I don't know about OS X, but on Windows Vista and later, there is 
os.environ['APPDATA']. I don't explicitly check for OS; instead, I see if
APPDATA exists as an environment variable:
try:
user_data_dir = os.path.join(os.environ['APPDATA'], 'NoiseBot')
except KeyError:
user_data_dir = os.path.join(os.environ['HOME'], '.NoiseBot')

I didn't even know that such a thing existed on OS X.
-- 
CPython 3.3.2 | Windows NT 6.2.9200 / FreeBSD 10.0
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Getting the Appdata Directory with Python and PEP?

2013-11-25 Thread Mark Lawrence

On 25/11/2013 20:48, Eamonn Rea wrote:

I've heard that there is a library that allows you to get the appdata directory 
for a given OS, but I'd like to do it myself, as a learning experience.

Is there a built in way to get a users Appdata Directory? For example on OS X 
it's in '~/Library//Application Support/'. I can get the OS just fine 
(sys.platform and then storing it in my own way; example: darwin = OS X, just 
for my own readability), and I can get the home directory just fine 
(expanduser), but I have no idea how to get the appdata directory.

One way I could think of doing it would be to just detect the os and join the 
string on like so (completely untested, but an idea);

if os == 'OS X':
 appdata_dir = os.path.join(home_dir, '/Application Support/')

But then that arises the problem of cross platform compatibility.

So is here a good, cross platform solution to this problem?


Take a look here 
http://docs.python.org/3/library/os.html#process-parameters, 
specifically os.environ.




Also, what is PEP, PEP8, etc? Is it like the Python programming layout 
conventions? Is there more to it than that?


PEP stands for Python Enhancement Proposal, please see 
http://www.python.org/dev/peps/  PEP8 is the style guide for Python code.


--
Python is the second best programming language in the world.
But the best has yet to be invented.  Christian Tismer

Mark Lawrence

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


parsing nested unbounded XML fields with ElementTree

2013-11-25 Thread larry.mart...@gmail.com
I have an XML file that has an element called "Node". These can be nested to 
any depth and the depth of the nesting is not known to me. I need to parse the 
file and preserve the nesting. For exmaple, if the XML file had:


   
  

  

When I'm parsing Node "E" I need to know I'm in A/B/C/D/E. Problem is I don't 
know how deep this can be. This is the code I have so far:

nodes = []

def parseChild(c):
if c.tag == 'Node':
if 'Name' in c.attrib: 
nodes.append(c.attrib['Name'])
for c1 in c:
parseChild(c1)
else:
for node in nodes:
print node,
print c.tag

for parent in tree.getiterator():
for child in parent:
for x in child:
parseChild(x)

My problem is that I don't know when I'm done with a node and I should remove a 
level of nesting. I would think this is a fairly common situation, but I could 
not find any examples of parsing a file like this. Perhaps I'm going about it 
completely wrong.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: parsing nested unbounded XML fields with ElementTree

2013-11-25 Thread Chris Angelico
On Tue, Nov 26, 2013 at 9:22 AM, larry.mart...@gmail.com
 wrote:
> I have an XML file that has an element called "Node". These can be nested to 
> any depth and the depth of the nesting is not known to me. I need to parse 
> the file and preserve the nesting. For exmaple, if the XML file had:
>
> 
>
>   
> 
>   

First off, please clarify: Are there five corresponding  tags
later on? If not, it's not XML, and nesting will have to be defined
some other way.

Secondly, please get off Google Groups. Your initial post is
malformed, and unless you specifically fight the software, your
replies will be even more malformed, to the point of being quite
annoying. There are many other ways to read a newsgroup, or you can
subscribe to the mailing list python-list@python.org, which carries
the same content.

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


Re: calculate part of solid circle in 2D array

2013-11-25 Thread Gregory Ewing

Gene Heskett wrote:
Your 1 degree assumption is, generally 
speaking, an extremely coarse answer in terms of the accuracy needed, as we 
need accuracies a lot closer to an arc-second than to a whole degree in 
robotics.


That may be true for some applications, but somehow I doubt
that a sonar beam 30 degrees wide would be able to locate
an object with arc-second accuracy.

We should be asking the OP, though. How coarse is the grid?
What kind of angular resolution is needed?

If the grid isn't too fine, I'd suggest doing something very
simple: Iterate over all the cells in the bounding rectangle
of the arc, and test whether each one is inside it.

There are two parts to that: is it inside the circle, and
is it between the two bounding lines?

Both of these can be answered with some straightforward
arithmetic. It's inside the circle if x*x + y*y <= r*r,
and a couple of vector dot products will answer the other
one. You can probably find a way to do all that in
parallel using numpy.

That leaves finding the slopes of the bounding lines.
Using trig is probably fast enough for that -- it's only
a couple of trig calls for the whole thing, which in
Python will be totally swamped by all the other calculations
you're doing. Or if you really want to avoid trig, use
a lookup table.

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


Re: cx_Oracle throws: ImportError: DLL load failed: This application has failed to start ...

2013-11-25 Thread Chris Angelico
On Tue, Nov 26, 2013 at 7:22 AM, Ruben van den Berg
 wrote:
> I haven't the slightest clue why version 11 just - wouldn't - run but due to 
> backward compatibility it seems a stressful weekend got a happy ending anyway.

Doesn't make particular sense to me either, but I don't know anything
about Oracle :) Glad it's working, anyhow. If nothing else, you have a
clean installation of version 12, so if your v11 was wrong in some
way, this simply sidestepped it. Often that's the easiest fix.

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


Re: How to determine whether client and server are on the same host

2013-11-25 Thread Chris Angelico
On Tue, Nov 26, 2013 at 6:35 AM, Malte Forkel  wrote:
> I have a Python application that communicates with a server via telnet.
> Host and port of the server are supplied by the user when the
> application is started.
>
> How can I determine from within the application whether the server's
> host actually is the local host? (In that case I could implement an
> operation not available in the telnet-based protocol by directly
> accessing the local filesystem.)

Two easy ways you could do this. I would be inclined to do what
PostgreSQL and others do, and have an explicit indication that you
want to use a local method: for instance, the name "localhost". Use of
anything else (including "127.0.0.1") means you use TCP/IP as normal,
but the strict word "localhost", which is normally equivalent to the
address 127.0.0.1, would signal your app to use the direct method (for
PostgreSQL, that's a Unix socket rather than a TCP one). This means
you can still force telnet to be used even if you're working locally -
good for debugging.

Alternatively, you can simply query the current network interfaces for
their IPs, and see if the IP you were given is in that list. I don't
know of a way to do that in core Python, but the C function you need
is getifaddrs(), and this claims to wrap all that up nicely:

https://pypi.python.org/pypi/netifaces

This method would detect, for instance, that calling up 192.168.0.19
port 12345 is a local lookup, because eth0 has address 192.168.0.19,
and that 192.168.2.2 port 54321 is local too, because wlan0 has
address 192.168.2.2.

If you aren't too concerned with running this on multiple platforms
(which seems likely - working with the local filesystem implies you
know a lot about what the server and client are doing), you could
simply parse the output of 'ip addr', 'ipconfig', 'ifconfig', or some
equivalent network utility for your platform. That might be easier
than playing with the package, depending on environment. But it'd be
even simpler - and in some ways better - to be explicit about "use a
direct connection rather than TCP".

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


Re: parsing nested unbounded XML fields with ElementTree

2013-11-25 Thread Larry Martell
On Monday, November 25, 2013 5:30:44 PM UTC-5, Chris Angelico wrote:

> On Tue, Nov 26, 2013 at 9:22 AM, larry.mart...@gmail.com
>
>  wrote:
>
> > I have an XML file that has an element called "Node". These can be nested 
> > to any depth and the depth of the nesting is not known to me. I need to 
> > parse the file and preserve the nesting. For exmaple, if the XML file had:
>
> >
>
> > 
> >
> >   
> > 
> >   
>
>
>
> First off, please clarify: Are there five corresponding  tags
> later on? If not, it's not XML, and nesting will have to be defined
> some other way.

Yes, there are corresponding  tags. I just didn't show them.

> Secondly, please get off Google Groups. Your initial post is
> malformed, and unless you specifically fight the software, your
> replies will be even more malformed, to the point of being quite
> annoying. There are many other ways to read a newsgroup, or you can
> subscribe to the mailing list python-list@python.org, which carries
> the same content.

Not sure what you mean by malformed. I don't really care for Google
Groups, but I've been using it to post to this any other groups for
years (since rn and deja news went away) and no one ever said my posts
were malformed. In any case, I did not know the group was available as
a ML. I've subbed to that and will post that way.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: SetupTools

2013-11-25 Thread Ben Finney
Chandru Rajendran  writes:

> How can we set the target folder for the package in Setuptools?

You do it at install time. In other words, it's not up to the author of
‘setup.py’ to decide; it's for the administrator installing your package
(or whoever set the defaults on that specific machine) to decide where
it goes.

See http://docs.python.org/3/install/index.html> for the
instructions to the Setuptools user on how to install a distribution.

>  CAUTION - Disclaimer *
> This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely 
> for the use of the addressee(s). If you are not the intended recipient, 
> please 
[…]

This is nonsense (you are deliberately sending the message to a public
forum and thus the message is not confidential). Please stop using a
system that adds this boilerplate rubbish, and/or convince your system
administrators to remove it when sending to public forums.

-- 
 \“… Nature … is seen to do all things Herself and through |
  `\ herself of own accord, rid of all gods.” —Titus Lucretius |
_o__) Carus, c. 40 BCE |
Ben Finney

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


Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !

2013-11-25 Thread Gregory Ewing

Ned Batchelder wrote:

Let's please avoid veering off into rants about language

> and philosophy now.

Philosophy is totally on topic for this group:

http://www.youtube.com/watch?v=-2gJamguN04

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


Re: parsing nested unbounded XML fields with ElementTree

2013-11-25 Thread Chris Angelico
On Tue, Nov 26, 2013 at 9:45 AM, Larry Martell  wrote:
> On Monday, November 25, 2013 5:30:44 PM UTC-5, Chris Angelico wrote:
>
>> First off, please clarify: Are there five corresponding  tags
>> later on? If not, it's not XML, and nesting will have to be defined
>> some other way.
>
> Yes, there are corresponding  tags. I just didn't show them.

Good good, I just saw the "unbounded" in your subject line and got
worried :) I'm pretty sure there's a way to parse that will preserve
the current nesting information, but others can describe that better
than I can.

>> Secondly, please get off Google Groups. Your initial post is
>> malformed, and unless you specifically fight the software, your
>> replies will be even more malformed, to the point of being quite
>> annoying. There are many other ways to read a newsgroup, or you can
>> subscribe to the mailing list python-list@python.org, which carries
>> the same content.
>
> Not sure what you mean by malformed. I don't really care for Google Groups,
> but I've been using it to post to this any other groups for years (since rn
> and deja news went away) and no one ever said my posts were malformed. In
> any case, I did not know the group was available as a ML. I've subbed to
> that and will post that way.

The mailing list works well for me too. Google Groups is deceptively
easy for a lot of people, but if you look through the list's archives,
you'll see that the posts it makes are unwrapped (and thus string out
to the right an arbitrary length), and all quoted text is
double-spaced, among other problems. Its users are generally unaware
of this, and like you are not maliciously inflicting that on us all,
but that doesn't make it any less painful to read :) Thanks for
switching.

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


general ConfigParser question

2013-11-25 Thread Rita
Hi,

I was wondering if the default ConfigParser can handle multi line strings
(especially in the relate section)

For example, if i have system.ini

[Global]
memory = 1024

[Process A]
command = sleep
arguments = 100

[Process B]
command = nslookup
arguments = hostA
output = data

[Process C]
command = checksum
arguments = data

[Relate]
data="parent process A child process B
Parent process B child process C
"


--- Get your facts first, then you can distort them as you please.--
-- 
https://mail.python.org/mailman/listinfo/python-list


Cracking hashes with Python

2013-11-25 Thread TheRandomPast
Hi, 

I have a school project to do where I've to download MD5 Hashes from a 
particular website and write a code that will crack them. Does anyone know 
where I'll find out more information on how to do this? There's only 4 hashes 
that I need to do so it doesn't have to be a large script just needs to be able 
to download the hashes from the website. Can anyone help me out?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python for everyday tasks

2013-11-25 Thread Ben Finney
Chris Angelico  writes:

> (Fifteen years. It's seventeen years since Unicode 2.0, when 16-bit
> characters were outmoded. It's about time _every_ modern language
> followed Python's and Pike's lead and got its Unicode support right.)

Most languages that already have some support for Unicode have a
significant amount of legacy code to continue supporting, though. Python
has the same problem: there're still heaps of Python 2 deployments out
there, and more being installed every day, none of which do Unicode
right.

To fix Unicode support in Python, the developers and community had to
initiate – and is still working through – a long, high-effort transition
across a backward-incompatible change in order to get the community to
Python 3, which finally does Unicode right.

Other language communities will likely have to do a similar huge effort,
or forever live with nearly-right-but-fundamentally-broken Unicode
support.

See, for example, the enormous number of ECMAScript deployments in every
user-facing browser, all with the false assumption (§2 of ECMA-262
http://www.ecma-international.org/publications/standards/Ecma-262.htm>)
that UTF-16 and Unicode are the same thing and nothing outside the BMP
exists.

And ECMAScript is near the front of the programming language pack in
terms of Unicode support — most others have far more heinous flaws that
need to be fixed by breaking backward compatibility. I wish their
communities luck.

-- 
 \ “Nature hath given men one tongue but two ears, that we may |
  `\  hear from others twice as much as we speak.” —Epictetus, |
_o__)  _Fragments_ |
Ben Finney

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


Re: How to determine whether client and server are on the same host

2013-11-25 Thread Ben Finney
Malte Forkel  writes:

> I have a Python application that communicates with a server via
> telnet. Host and port of the server are supplied by the user when the
> application is started.
>
> How can I determine from within the application whether the server's
> host actually is the local host? (In that case I could implement an
> operation not available in the telnet-based protocol by directly
> accessing the local filesystem.)

On Unix, this is up to the person invoking the program: the “sockets
facility allows for a host-local connection to appear as though it's
going over a network.

https://en.wikipedia.org/wiki/Localhost>
https://en.wikipedia.org/wiki/Unix_domain_socket>

In other words: Your program shouldn't go snooping around to
second-guess the connection type; if the user asked for a TCP/IP
connection, that's what they should get. If they want to take advantage
of a local connection, they can use a Unix domain socket.

-- 
 \ “I wrote a song, but I can't read music so I don't know what it |
  `\is. Every once in a while I'll be listening to the radio and I |
_o__)say, ‘I think I might have written that.’” —Steven Wright |
Ben Finney

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


Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !

2013-11-25 Thread Larry Martell
On Mon, Nov 25, 2013 at 6:12 PM, Gregory Ewing
wrote:

> Ned Batchelder wrote:
>
>> Let's please avoid veering off into rants about language
>>
> > and philosophy now.
>
> Philosophy is totally on topic for this group:
>
> http://www.youtube.com/watch?v=-2gJamguN04
>
> A classic! I hadn't seen that in many years.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Cracking hashes with Python

2013-11-25 Thread Chris Angelico
On Tue, Nov 26, 2013 at 10:32 AM, TheRandomPast  wrote:
> I have a school project to do where I've to download MD5 Hashes from a 
> particular website and write a code that will crack them. Does anyone know 
> where I'll find out more information on how to do this? There's only 4 hashes 
> that I need to do so it doesn't have to be a large script just needs to be 
> able to download the hashes from the website. Can anyone help me out?

Do you actually need to download them from that web site, or can you
simply embed them into your code? The latter would be far easier.

I'm going to assume that you don't need to do anything more
complicated than brute-force these, and I'll also assume that they're
unsalted hashes.

With a cryptographic hash function, you take text, put it into the
function, and get back a number (or a hex or binary string, which
comes to the same thing). You can't go from the number to the string;
however, you can generate a large number of strings to see if any of
them results in the same number. You can take "large number" all the
way, and generate every possible string of a certain length, or you
can go through a dictionary and generate words. Once you find
something that matches, you have a plausible guess that this is the
password.

There's a basic idea of what "cracking" a hash means. Put a bit of
code together, see how you go. If you get stuck, post your code and
how you're stuck, and we'll try to help; but we won't simply write
your code for you. (By the way, thanks for being up-front about it
being a school project. The honesty is appreciated, even though we
would almost certainly be able to tell even if you didn't. :) )

One last thing: Please get off Google Groups. It makes your posts look
ugly, which makes you look bad, and that's (probably!) unfair. Use a
better news client, or subscribe to the mailing list
python-list@python.org and read and post through that. There are a
number of regulars here who simply trash all Google Groups posts
unread, because they're just not worth reading - switching clients
will help you be heard, and will mean you don't annoy people with
form. Of course, if you want to annoy us with substance, that's your
God-given right. :)

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


Re: parsing nested unbounded XML fields with ElementTree

2013-11-25 Thread Larry Martell
On Mon, Nov 25, 2013 at 6:19 PM, Chris Angelico  wrote:

> On Tue, Nov 26, 2013 at 9:45 AM, Larry Martell 
> wrote:
> > On Monday, November 25, 2013 5:30:44 PM UTC-5, Chris Angelico wrote:
> >
> >> First off, please clarify: Are there five corresponding  tags
> >> later on? If not, it's not XML, and nesting will have to be defined
> >> some other way.
> >
> > Yes, there are corresponding  tags. I just didn't show them.
>
> Good good, I just saw the "unbounded" in your subject line and got
> worried :) I'm pretty sure there's a way to parse that will preserve
> the current nesting information, but others can describe that better
> than I can.
>

The term 'unbounded' is used in the XML xsd file like this:




> >> Secondly, please get off Google Groups. Your initial post is
> >> malformed, and unless you specifically fight the software, your
> >> replies will be even more malformed, to the point of being quite
> >> annoying. There are many other ways to read a newsgroup, or you can
> >> subscribe to the mailing list python-list@python.org, which carries
> >> the same content.
> >
> > Not sure what you mean by malformed. I don't really care for Google
> Groups,
> > but I've been using it to post to this any other groups for years (since
> rn
> > and deja news went away) and no one ever said my posts were malformed. In
> > any case, I did not know the group was available as a ML. I've subbed to
> > that and will post that way.
>
> The mailing list works well for me too. Google Groups is deceptively
> easy for a lot of people, but if you look through the list's archives,
> you'll see that the posts it makes are unwrapped (and thus string out
> to the right an arbitrary length), and all quoted text is
> double-spaced, among other problems. Its users are generally unaware
> of this, and like you are not maliciously inflicting that on us all,
> but that doesn't make it any less painful to read :) Thanks for
> switching.
>
>
I had noticed the double spacing and I always fixed that when I replied.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Cracking hashes with Python

2013-11-25 Thread TheRandomPast
On Monday, 25 November 2013 23:47:52 UTC, Chris Angelico  wrote:
> On Tue, Nov 26, 2013 at 10:32 AM, TheRandomPast wrote:
> 
> > I have a school project to do where I've to download MD5 Hashes from a 
> > particular website and write a code that will crack them. Does anyone know 
> > where I'll find out more information on how to do this? There's only 4 
> > hashes that I need to do so it doesn't have to be a large script just needs 
> > to be able to download the hashes from the website. Can anyone help me out?
> 
> 
> 
> Do you actually need to download them from that web site, or can you
> 
> simply embed them into your code? The latter would be far easier.
> 
> 
> 
> I'm going to assume that you don't need to do anything more
> 
> complicated than brute-force these, and I'll also assume that they're
> 
> unsalted hashes.
> 
> 
> 
> With a cryptographic hash function, you take text, put it into the
> 
> function, and get back a number (or a hex or binary string, which
> 
> comes to the same thing). You can't go from the number to the string;
> 
> however, you can generate a large number of strings to see if any of
> 
> them results in the same number. You can take "large number" all the
> 
> way, and generate every possible string of a certain length, or you
> 
> can go through a dictionary and generate words. Once you find
> 
> something that matches, you have a plausible guess that this is the
> 
> password.
> 
> 
> 
> There's a basic idea of what "cracking" a hash means. Put a bit of
> 
> code together, see how you go. If you get stuck, post your code and
> 
> how you're stuck, and we'll try to help; but we won't simply write
> 
> your code for you. (By the way, thanks for being up-front about it
> 
> being a school project. The honesty is appreciated, even though we
> 
> would almost certainly be able to tell even if you didn't. :) )
> 
> 
> 
> One last thing: Please get off Google Groups. It makes your posts look
> 
> ugly, which makes you look bad, and that's (probably!) unfair. Use a
> 
> better news client, or subscribe to the mailing list
> 
> python-list@python.org and read and post through that. There are a
> 
> number of regulars here who simply trash all Google Groups posts
> 
> unread, because they're just not worth reading - switching clients
> 
> will help you be heard, and will mean you don't annoy people with
> 
> form. Of course, if you want to annoy us with substance, that's your
> 
> God-given right. :)
> 
> 
> 
> ChrisA

Hi, thanks for replying. I don't like google groups layout either I was just 
unsure as to what to use. I already have some code on the go I just couldn't 
figure out the best way to do what I wanted to do so I thought I'd ask and see 
if anyone could point me in the right direction. I *have* to download them, i 
know how many there are because I used a text editor to find them. 

What client do you suggest I use instead of google groups?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python for everyday tasks

2013-11-25 Thread Chris Angelico
On Tue, Nov 26, 2013 at 10:35 AM, Ben Finney  wrote:
> Chris Angelico  writes:
>
>> (Fifteen years. It's seventeen years since Unicode 2.0, when 16-bit
>> characters were outmoded. It's about time _every_ modern language
>> followed Python's and Pike's lead and got its Unicode support right.)
>
> Most languages that already have some support for Unicode have a
> significant amount of legacy code to continue supporting, though. Python
> has the same problem: there're still heaps of Python 2 deployments out
> there, and more being installed every day, none of which do Unicode
> right.
>
> To fix Unicode support in Python, the developers and community had to
> initiate – and is still working through – a long, high-effort transition
> across a backward-incompatible change in order to get the community to
> Python 3, which finally does Unicode right.

Yes, but Python can start that process by creating Python 3; other
languages ought to be able to do something similar. Get the process
started. It's not going to get any easier by waiting.

And, more importantly: New languages are being developed. If their
designers look at Java, they'll see "UTF-16 is fine for them, so it'll
be fine for us", but if they look at Python, they'll see "The current
version of Python does it this way, everything else is just
maintenance mode, so this is obviously the way the Python designers
feel is right". Even if 99% of running Python code is Py2, that
message is still being sent, because Python 2.8 will never exist.

> Other language communities will likely have to do a similar huge effort,
> or forever live with nearly-right-but-fundamentally-broken Unicode
> support.
>
> See, for example, the enormous number of ECMAScript deployments in every
> user-facing browser, all with the false assumption (§2 of ECMA-262
> http://www.ecma-international.org/publications/standards/Ecma-262.htm>)
> that UTF-16 and Unicode are the same thing and nothing outside the BMP
> exists.
>
> And ECMAScript is near the front of the programming language pack in
> terms of Unicode support — most others have far more heinous flaws that
> need to be fixed by breaking backward compatibility. I wish their
> communities luck.

Yeah. I'm now of the opinion that JavaScript and ECMAScript can't be
fixed ("use strict" is entirely backward compatible, but changing
string handling wouldn't be), so it's time we had a new web browser
scripting language. Really, 1996 was long enough ago that using 16-bit
characters should be considered no less wrong than 8-bit characters.
If it weren't that we don't actually need the space any time soon, I
would consider the current limit of 11141112 characters to be a
problem too; there's really no reason to restrict ourselves based on
what UTF-16 is capable of encoding any more than we should define
Unicode based on what Code Page 437 can handle.

>  \ “Nature hath given men one tongue but two ears, that we may |
>   `\  hear from others twice as much as we speak.” —Epictetus, |
> _o__)  _Fragments_ |

One of my brothers just got married, and someone who's friended him on
Facebook was unaware of the invitations despite being a prolific
poster. I cited the modern equivalent of the above, namely that we
have ten fingers but only two eyes, so it's acceptable to write five
times as much as we actually bother to read...

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


Re: Cracking hashes with Python

2013-11-25 Thread Chris Angelico
On Tue, Nov 26, 2013 at 11:01 AM, TheRandomPast  wrote:
> Hi, thanks for replying. I don't like google groups layout either I was just 
> unsure as to what to use. I already have some code on the go I just couldn't 
> figure out the best way to do what I wanted to do so I thought I'd ask and 
> see if anyone could point me in the right direction. I *have* to download 
> them, i know how many there are because I used a text editor to find them.
>
> What client do you suggest I use instead of google groups?

Personally, I use the mailing list:

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

You can sign up by email, read the emails, respond to emails.
Alternatively, look for a news client for your platform - Mozilla
Thunderbird is a popular option.

Downloading the hashes from the web site depends a bit on how they're
formatted. Do you get a plain text file with one per line? Are they
given in hex? How is it all laid out?

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


Re: general ConfigParser question

2013-11-25 Thread Tim Chase
On 2013-11-25 18:32, Rita wrote:
> I was wondering if the default ConfigParser can handle multi line
> strings (especially in the relate section)
> 
> [Relate]
> data="parent process A child process B
> Parent process B child process C

Yes, though I seem to recall that subsequent lines have to be
indented:

>>> from ConfigParser import ConfigParser as cp
>>> from StringIO import StringIO
>>> sio = StringIO("""[global]
... one ="first
... second
... third"
... """)
>>> c = cp()
>>> c.readfp(sio)
>>> c.get("global", "one")  # Note2: quotes
'"first\nsecond\nthird"'
>>> sio = StringIO("""[global]
... one =first
... second
... third
...""")
>>> c = cp()
>>> c.readfp(sio)
>>> c.get("global", "one")  # Note2: no quotes
'first\nsecond\nthird'

Note1: this also strips off leading whitespace on the subsequent
lines.

Note2: if you quote the values, they appear in the resulting value.

So based on this, I occasionally do like CherryPy does and require
quotes, then wrap my cp.get(section, name) results in a
ast.literal_eval() call to get the corresponding Python result.
Alternatively, you can use the cp.getint(), cp.getbool() and
cp.getfloat() calls.

-tkc



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


Re: general ConfigParser question [PS]

2013-11-25 Thread Tim Chase
On 2013-11-25 18:29, Tim Chase wrote:
> On 2013-11-25 18:32, Rita wrote:
> > I was wondering if the default ConfigParser can handle multi line
> > strings (especially in the relate section)
> > 
> > [Relate]
> > data="parent process A child process B
> > Parent process B child process C
> 
> Yes, though I seem to recall that subsequent lines have to be
> indented

Just following up, it's mentioned in the docs, but it's easy to miss:

"""with continuations in the style of RFC 822 (see section 3.1.1,
“LONG HEADER FIELDS”);"""

-tkc


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


RE: Cracking hashes with Python

2013-11-25 Thread Marc
Hashes, by definition, are not reversible mathematically.  The only way to
figure out what they represent is to take plaintext that might be the
plaintext based on anything you might know about the original plaintext
(which is often nothing) and hash it; then see if the hash matches the one
you have.  If it does, you have figured out the plaintext; if it doesn't try
again.  For a tool that does this, look at Rainbow tables.


-original message--
Hi, 

I have a school project to do where I've to download MD5 Hashes from a
particular website and write a code that will crack them. Does anyone know
where I'll find out more information on how to do this? There's only 4
hashes that I need to do so it doesn't have to be a large script just needs
to be able to download the hashes from the website. Can anyone help me out?

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


Re: Excute script only from another file

2013-11-25 Thread Rick Johnson
On Monday, November 25, 2013 4:52:46 AM UTC-6, Himanshu Garg wrote:

> My motive is "I will give scripts to somebody else and he
> should not run the script directly without running the 
> parent script".

The only sure fire method to prevent a file containing
Python code from executing on a machine with Python
installed is to use an extension that the system will not
associate with Python.

 ScriptFolder/
   script.py
   mod_1.ignore
   mod_2.ignore
   ...

Of course, any other Python module that needs to leverage
the API contained within the "aliased mod files" will need
to do so *manually*:

 1. Read the file from disc
 2. Evaluate the file contents and make callable
 3. Close the file

Sounds like your distributing a Python application and need
a simplistic method by which "non-techies" can run the code,
but as we all know:

 "fools are too cleaver!"

Of course a smarty pants could could change the extension to 
"py[w]", but that would be violating your interface. :) 

Another choice would be to use a package.

 ScriptPackageFolder/
   __init__.py
   __script.py
   mod_1.py
   mod_2.py
   ...

But nothing could stop them from accessing the contents of
the package directory. 

A third alternative would be to install the support modules
in a place that the user would be unlikely to look and then
place a mainscript somewhere that is easily accessible. But
even this method will not prevent the running of py scripts.

Sounds like my first offering is the best. At least with 
that method they would be forced into an explicit act of 
renaming the file before they violate your interface.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Excute script only from another file

2013-11-25 Thread Chris Angelico
On Tue, Nov 26, 2013 at 1:28 PM, Rick Johnson
 wrote:
> The only sure fire method to prevent a file containing
> Python code from executing on a machine with Python
> installed is to use an extension that the system will not
> associate with Python.
>
>  ScriptFolder/
>script.py
>mod_1.ignore
>mod_2.ignore
>...

Windows:
C:\Documents and Settings\M>copy con test.ignore
print("Hello, world!")
^Z
1 file(s) copied.

C:\Documents and Settings\M>python test.ignore
Hello, world!

Linux:
gideon@gideon:~$ cat >test.ignore
print("Hello, world!")
gideon@gideon:~$ python test.ignore
Hello, world!

Totally sure-fire. Absolutely prevents any execution until it's
renamed. By the way, what does "associate" mean, and what does it have
to do with file names?

gideon@gideon:~$ cat >test.ignore
#!/usr/bin/python
print("Hello, world!")
gideon@gideon:~$ chmod +x test.ignore
gideon@gideon:~$ ./test.ignore
Hello, world!

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


Re: Cracking hashes with Python

2013-11-25 Thread Steven D'Aprano
On Mon, 25 Nov 2013 15:32:41 -0800, TheRandomPast wrote:

> Hi,
> 
> I have a school project to do where I've to download MD5 Hashes from a
> particular website and write a code that will crack them.

A school project. Right. Heh. :-)

And which website's hashes would this be?


> Does anyone
> know where I'll find out more information on how to do this? There's
> only 4 hashes that I need to do so it doesn't have to be a large script
> just needs to be able to download the hashes from the website. Can
> anyone help me out?

The size of the script has nothing to do with the number of hashes you 
have to crack. Whether it is one hash and one million, the script will be 
exactly the same.

Do you have to write a program to download the hashes, or can you just 
browse to the web address with your browser and save them?

If you have to write your own program, start here:

https://duckduckgo.com/?q=python+how+to+download+data+from+the+web


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


Re: Excute script only from another file

2013-11-25 Thread Steven D'Aprano
On Mon, 25 Nov 2013 18:28:42 -0800, Rick Johnson wrote:

> On Monday, November 25, 2013 4:52:46 AM UTC-6, Himanshu Garg wrote:
> 
>> My motive is "I will give scripts to somebody else and he should not
>> run the script directly without running the parent script".
> 
> The only sure fire method to prevent a file containing Python code from
> executing on a machine with Python installed is to 
[snip bad advice]

... is to delete Python from the system, or the Python code. Or both.

If Python can read a file, it can exec it.

I suppose you could use file permissions and ACLs to prevent Python from 
reading the file, rather than delete it, but given the possibility of 
privilege-escalation security vulnerabilities, even that's not sure-fire.


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


Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !

2013-11-25 Thread Rick Johnson
On Monday, November 25, 2013 2:10:04 PM UTC-6, Ned Batchelder wrote:
> Let's please avoid veering off into rants about language
> and philosophy now.

Hello Ned. I respect the fact that you want to keep threads
on-topic, and i greatly appreciate the humbleness of your
request.

However, i feel as though i am being unfairly treated when
other people (who shall remain unnamed) started the
discussion in an off-topic direction long before i chimed
in.

And to be fair, i was merely retorting a hasty assertion by
our friend Steven. Yes, i might have gotten a bit
philosophical in the process, but the reply itself was
germane to the sub-topic that Steven propagated up.

Furthermore, I don't believe that applying ridged rules of
topicality are to the benefit of anyone. Conversations of
any topic are destined to spin-off in many seemingly 
unrelated directions -- and this is healthy!

As a spectator (or a participant) you can choose to stop
listening (or participating) at anytime the conversation
becomes uninteresting to you.

Some of the greatest debates that i have participated
in (those that result in epiphany or even catharsis) had
initially sprung out of seemingly unrelated subject matters
which slowly built to a crescendo of maximum intensity.

I don't think we should attempt to restrict debate since it 
is this very debate that results in evolution of not only
the participants, but also the spectators.

"Man's mind is his basic tool of survival. Life is
given to him, survival is not. His body is given to
him, its sustenance is not. His mind is given to
him, its content is not"

[...]

"Reason does not work automatically; thinking is not
a mechanical process; the connections of logic are
not made by instinct. The function of your stomach,
lungs or heart is automatic; the function of your
mind is not."

"In any hour and issue of your life, you are free to
think or to evade that effort. But you are not free
to escape from your nature, from the fact that
reason is your means of survival -- so that for you,
who are a human being, the question "to be or not to
be" is the question "to think or not to think."

-- Ayn Rand

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


Re: Excute script only from another file

2013-11-25 Thread Rick Johnson
On Monday, November 25, 2013 8:41:07 PM UTC-6, Chris Angelico wrote:

> Totally sure-fire. Absolutely prevents any execution until it's
> renamed. 

Doh! It seems Python's quite the sneaky little snake!

> By the way, what does "associate" mean, and what does it have
> to do with file names?

Hmm, I did not see his "command line snip-it" and assumed his users where not 
"command line savvy", therefor they would be running the script via a mouse 
click -- still probably not "sure fire" advice either. 

Okay, Rick was wrong once. get over it! :-P"
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Cracking hashes with Python

2013-11-25 Thread Frank Cui
Hi,
I'm assuming you are taking a computer/network security course.
Md5 hashing operation is designed to be mathematically unidirectional, you can 
only attempt to find a collision situation but it's technically impossible to 
reverse the operation.
With that said, it's possible to "crack" or "decrypt" a md5 hash value by 
searching through a value-hash database to find the most commonly used password 
under a given hash value. You can see the tool at http://www.md5crack.com/home.

Yatong

> From: st...@pearwood.info
> Subject: Re: Cracking hashes with Python
> Date: Tue, 26 Nov 2013 02:55:58 +
> To: python-list@python.org
> 
> On Mon, 25 Nov 2013 15:32:41 -0800, TheRandomPast wrote:
> 
> > Hi,
> > 
> > I have a school project to do where I've to download MD5 Hashes from a
> > particular website and write a code that will crack them.
> 
> A school project. Right. Heh. :-)
> 
> And which website's hashes would this be?
> 
> 
> > Does anyone
> > know where I'll find out more information on how to do this? There's
> > only 4 hashes that I need to do so it doesn't have to be a large script
> > just needs to be able to download the hashes from the website. Can
> > anyone help me out?
> 
> The size of the script has nothing to do with the number of hashes you 
> have to crack. Whether it is one hash and one million, the script will be 
> exactly the same.
> 
> Do you have to write a program to download the hashes, or can you just 
> browse to the web address with your browser and save them?
> 
> If you have to write your own program, start here:
> 
> https://duckduckgo.com/?q=python+how+to+download+data+from+the+web
> 
> 
> -- 
> Steven
> -- 
> https://mail.python.org/mailman/listinfo/python-list
  -- 
https://mail.python.org/mailman/listinfo/python-list


Re: Recursive generator for combinations of a multiset?

2013-11-25 Thread John O'Hagan
On Mon, 25 Nov 2013 12:15:15 +
Oscar Benjamin  wrote:

> On 21 November 2013 13:01, John O'Hagan 
> wrote:
> > In my use-case the first argument to multicombs is a tuple of words
> > which may contain duplicates, and it produces all unique
> > combinations of a certain length of those words, eg:
> >
> > list(multicombs(('cat', 'hat', 'in', 'the', 'the'), 3))
> >
> > [('cat', 'hat', 'in'), ('cat', 'hat', 'the'), ('cat', 'in', 'the'),
> > ('cat', 'the', 'the'), ('hat', 'in', 'the'), ('hat', 'the', 'the'),
> > ('in', 'the', 'the')]
> 
> I still don't understand what you're actually doing well enough to
> know whether there is a better general approach to the problem. For
> the specific thing you requested, here is a recursive multiset
> combinations generator. Does it do what you wanted?
> 
> #!/usr/bin/env python
> 
> def multicombs(it, r):
> words = []
> last = None
> for N, word in enumerate(it):
> if word == last:
> words[-1][1] += 1
> else:
> words.append([word, 1])
> last = word
> cumulative = 0
> for n in range(len(words)-1, -1, -1):
> words[n].append(cumulative)
> cumulative += words[n][1]
> return _multicombs((), words, r)
> 
> def _multicombs(prepend, words, r):
> if r == 0:
> yield prepend
> return
> (word, count, rem), *remaining = words
> for k in range(max(r-rem, 0), min(count, r) + 1):
> yield from _multicombs(prepend + (word,) * k, remaining, r-k)

Thanks, that is exactly the type of thing I was after. Although it is
actually slower as is than a hack like

def imulticombs(it, n):
last = ()
for i in itertools.combinations(it,n):
if i > last:
yield i
last = i

it can be modified to be a lot faster for my use-case like this:

def _multicombs(prepend, words, r, chkstr):
"""chkstr is the string of remaining availalable characters"""
if r == 0:
yield prepend, chkstr
return
(word, count, rem), *remaining = words
newstr = chkstr
for k in range(max(r-rem, 0), min(count, r) + 1):
for letter in word * k:
if letter in newstr:
newstr = newstr.replace(letter, '' , 1)
else:
return
yield from _multicombs(prepend + (word,) * k, remaining, r-k,
newstr)

By progressively checking against the available characters, it avoids
fruitless recursion branches. I'm not 100% sure I'm doing this right yet
but so far it's promising. This is the quickest non-redundant approach
I've used so far (although strangely, the original product-only version
which produces a lot of redundant results is still by far the quickest.)

This is how I'm calling it:

def cartesian_product(args, instr):
if not args:
yield (),instr
return
for items, chkstr in cartesian_product(args[:-1], instr):
#this prevents bothering with anything useless
words, repeats = args[-1]
if repeats == 1:
for word in words:
newstr = chkstr
for letter in word:
if letter in newstr:
newstr = newstr.replace(letter, '' , 1)
else:
break
else:
yield items + (word,), newstr
else:
for item, newstr in multicombs(words, repeats, chkstr):
yield items + item, newstr

I'll try to explain better what I'm actually doing. It's quite long,
but you seem to be wondering, or maybe someone else is!

It's an old anagram program I wrote for practice a few years ago which
produces the phrases of dictionary words which together contains the
same letter-multiset as the input phrase. I would be interested to know
if you think there is a better general approach. My approach is: 

- make a dictionary of candidate words composed of the same
  sub-alphabet as the input, using their lengths as keys, then
 
- for each integer partition of the length of the input, replace each
  partition element with the corresponding value from the dictionary,
  then 

- Take the cartesian product of the resulting list of lists of words,
  rejecting any output which exceeds any of the letter frequencies of
  the input 

I have omitted descibing some complex optimisations of the lists, which
gave only fractional speedups.

However, I recently discovered that I could get an orders-of-magnitude
speedup by using my own recursive cartesian product algorithnm which
checks letter frequencies on the fly, rather than using
itertools.product and testing each output phrase. (This algorithm was
in my original post). 

For example, take the phrase "break beat". I make a wordlength
dictionary of sub-alphabet words, using the system dictionary file,
like this:

 {1: ['a'], 2: ['at', 'be', 're'], 3: ['are', 'ark', 'art', 'ate',
 'baa', 'bar', 'bat', 'bee', 'bet', 'bra', 'ear', 'eat', 'ebb', 'eke',
 'er

Re: calculate part of solid circle in 2D array

2013-11-25 Thread Robert Voigtländer
Great discussion started here 

To answer some of the questions and to give more background:

-   The grid resolution is 1x1cm. The problem starts when the distance of 
the readings gets high. Then a 1° resolution doesn’t cover all cells anymore. 
And cells get counted double on short distance – which needs to be compensated. 
So for larger distances I need to get down to about 0.1 degree in reality to 
not miss cells.
-   So far I ran the logic for the robot on a PC. No problem here with the 
performance using trigonometry (in java). But I am on my way porting everything 
to a raspberry pi which will be on the robot itself.
Due to the limited calculation power I want to avoid too heavy calculation for 
regular jobs. The scans come in about every 40ms. So the calculation needs to 
be as fast as possible.
-   I surely will benchmark the new approach vs. the trigonometry solution 
which I will port from my current java solution. Maybe I will be surprised – 
but I think the trig approach will be slower.

The lookup table is also a great idea! I can produce it for any resolution 
needed and on runtime it is simply combining lists for the slices needed…..not 
bad.


So far I have the circle points as well as the lines – using the Brenham’s 
circle and line functions.
Code: http://pastebin.com/GzUzuAnb

I just need to get the filling done…..

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


Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !

2013-11-25 Thread Antoon Pardon
Op 25-11-13 21:00, Ethan Furman schreef:
> On 11/25/2013 11:53 AM, Antoon Pardon wrote:
>> Op 23-11-13 03:18, Steven D'Aprano schreef:
>>>
>>> As this is an international forum, it behoves us all to make allowances
>>> for slight difference in dialect.
>>
>> I don't see how that follows. I would say on the contrary. This being
>> an international forum people should try to reframe from burdening
>> lots of other people with expressions most people will not understand
>> or even misunderstand.
> 
> So we can assume you've made a comprehensive study of the different
> varieties of English and created a compendium of which words and/or
> phrases can be easily misunderstood?  Please share that with us, it
> would be quite helpful.

Well I can't stop you from assuming something like that, however it
wasn't implied by what I wrote.

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


Re: parsing nested unbounded XML fields with ElementTree

2013-11-25 Thread Stefan Behnel
larry.martell...@gmail.com, 25.11.2013 23:22:
> I have an XML file that has an element called "Node". These can be nested to 
> any depth and the depth of the nesting is not known to me. I need to parse 
> the file and preserve the nesting. For exmaple, if the XML file had:
> 
> 
>
>   
> 
>   
> 
> When I'm parsing Node "E" I need to know I'm in A/B/C/D/E. Problem is I don't 
> know how deep this can be. This is the code I have so far:
> 
> nodes = []
> 
> def parseChild(c):
> if c.tag == 'Node':
> if 'Name' in c.attrib: 
> nodes.append(c.attrib['Name'])
> for c1 in c:
> parseChild(c1)
> else:
> for node in nodes:
> print node,
> print c.tag
> 
> for parent in tree.getiterator():
> for child in parent:
> for x in child:
> parseChild(x)

This seems hugely redundant. tree.getiterator() already returns a recursive
iterable, and then, for each nodes in your document, you are running
recursively over its entire subtree. Meaning that you'll visit each node as
many times as its depth in the tree.


> My problem is that I don't know when I'm done with a node and I should
> remove a level of nesting. I would think this is a fairly common
> situation, but I could not find any examples of parsing a file like
> this. Perhaps I'm going about it completely wrong.

Your recursive traversal function tells you when you're done. If you drop
the getiterator() bit, reaching the end of parseChild() means that you're
done with the element and start backing up. So you can simply pass down a
list of element names that you append() at the beginning of the function
and pop() at the end, i.e. a stack. That list will then always give you the
current path from the root node.

Alternatively, if you want to use lxml.etree instead of ElementTree, you
can use it's iterwalk() function, which gives you the same thing but
without recursion, as a plain iterator.

http://lxml.de/parsing.html#iterparse-and-iterwalk

Stefan


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


Re: Got a Doubt ! Wanting for your Help ! Plz make it ASAP !

2013-11-25 Thread Antoon Pardon
Op 25-11-13 21:05, Joel Goldstick schreef:
>>> I'm not an expert on Indian English, but I understand that in that
>>> dialect it is grammatically correct to say "the codes", just as in UK and
>>> US English it is grammatically correct to say "the programs".
>>>
>>> In other words, in UK/US English, "code" in the sense of programming code
>>> is an uncountable noun, like "rice" or "air", while in Indian English it
>>> is a countable noun like cats or programs. We have to say "give me two
>>> samples of code", or perhaps "two code samples", while an Indian speaker
>>> might say "give me two codes".
>>>
>>> As this is an international forum, it behoves us all to make allowances
>>> for slight difference in dialect.
>>
>> I don't see how that follows. I would say on the contrary. This being
>> an international forum people should try to reframe from burdening
>> lots of other people with expressions most people will not understand
>> or even misunderstand.
>>
>> --
>> Antoon Pardon
>> --
>> https://mail.python.org/mailman/listinfo/python-list
> 
> 
> I see the different idioms as kind of interesting, and funny
> sometimes, but I don't think they pose a big barrier.

IMO that is because the differences in idoms you have seen here
are very minor and yet Roy already found it necessary to explain
the specific use of "doubt" by the OP.

Not that I mind that much but as has been said multiple times, a
contribution is only written once and read many times. So I think
we may expect more effort from the writer in trying to be
understandable than from the readers in trying to understand. And
that includes idiom use.

> Mostly, people
> don't provide OS or python version, or explain what they done and what
> happens.  That makes it harder to respond than figuring out how
> different people around the world say stuff.  I'm from US and I have
> done lots of phone calls with Indian developers.  To me it sounds
> strange to talk about codes, but I totally understand what they mean.

That is fine for you. But can you expect a random reader from
comp.lang.python to understand that without any explanation?

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