Re: Python equivalent to the "A" or "a" output conversions in C

2012-06-19 Thread Aldrich DeMata
Use the binascii module: >>> import numpy as np >>> x = np.float32(3.14) >>> x.dtype dtype('float32') >>> binascii.hexlify(x) 'c3f54840' The final result is little endian so it should be read as 0x4048f5c3 instead. You can verify the conversion using the link below: http://gregstoll.dyndns.org/~

Re: Tkinter binding question

2012-06-19 Thread rantingrickjohnson
On Tuesday, June 19, 2012 10:55:48 AM UTC-5, Frederic Rentsch wrote: > If I copy your event descriptors into my program, the button-release > callback still fails. It works in your code, not in mine. Here is what > my code now looks like. It is somewhat more complicated than yours, > because I bind

Re: Py3.3 unicode literal and input()

2012-06-19 Thread Steven D'Aprano
On Mon, 18 Jun 2012 07:00:01 -0700, jmfauth wrote: > On 18 juin, 12:11, Steven D'Aprano +comp.lang.pyt...@pearwood.info> wrote: >> On Mon, 18 Jun 2012 02:30:50 -0700, jmfauth wrote: >> > On 18 juin, 10:28, Benjamin Kaplan wrote: >> >> The u prefix is only there to >> >> make it easier to port a

Re: Finding absolute path of imported module?

2012-06-19 Thread Gelonida N
On 06/19/2012 09:32 PM, Christian Heimes wrote: Am 19.06.2012 19:55, schrieb Roy Smith: So, the question is, is there any way to dump all the *absolute* pathnames of all the imported modules? I can iterate over sys.modules.values(), but that doesn't give me absolute pathnames, so I can't tell w

Re: "constant sharing" works differently in REPL than in script ?

2012-06-19 Thread Chris Angelico
On Wed, Jun 20, 2012 at 7:21 AM, wrote: > I liked your code Chris demoing the different ranges in different versions. I > tried to write something like that myself but you did it an awful lot better ! There's no guarantee that it'll prove which are and aren't cached, but it does seem to work. (

Re: "constant sharing" works differently in REPL than in script ?

2012-06-19 Thread shearichard
Thanks for all the replies. I hadn't thought about the opportunities that exist for optimization when the whole script is there (or when compound operations are taking place) by contrast with plain old REPL ops. I liked your code Chris demoing the different ranges in different versions. I tried

Re: Python equivalent to the "A" or "a" output conversions in C

2012-06-19 Thread jmfauth
On Jun 19, 9:54 pm, "Edward C. Jones" wrote: > On 06/19/2012 12:41 PM, Hemanth H.M wrote: > > > >>> float.hex(x) > > '0x1.5p+3' > > Some days I don't ask the brightest questions.  Suppose x was a numpy > floating scalar (types numpy.float16, numpy.float32, numpy.float64, or > numpy.flo

Re: Python equivalent to the "A" or "a" output conversions in C

2012-06-19 Thread Edward C. Jones
On 06/19/2012 12:41 PM, Hemanth H.M wrote: >>> float.hex(x) '0x1.5p+3' Some days I don't ask the brightest questions. Suppose x was a numpy floating scalar (types numpy.float16, numpy.float32, numpy.float64, or numpy.float128). Is there an easy way to write x in binary or hex?

Re: Finding absolute path of imported module?

2012-06-19 Thread Christian Heimes
Am 19.06.2012 19:55, schrieb Roy Smith: > So, the question is, is there any way to dump all the *absolute* > pathnames of all the imported modules? I can iterate over > sys.modules.values(), but that doesn't give me absolute pathnames, so > I can't tell which version of the symlink existed when th

Finding absolute path of imported module?

2012-06-19 Thread Roy Smith
We're trying to debug a weird (and, of course, intermittent) problem a gunicorn-based web application. Our production directory structure looks like: deploy/ rel-2012-06-14/ rel-2012-06-12/ rel-2012-06-11/ current -> rel-2012006-14 Each time we deploy a new version, we create a new relea

Re: Python equivalent to the "A" or "a" output conversions in C

2012-06-19 Thread Mark Lawrence
On 19/06/2012 17:23, Edward C. Jones wrote: Consider the following line in C: printf('%a\n', x); where x is a float or double. This outputs a hexadecimal representation of x. Can I do this in Python? See this http://docs.python.org/library/string.html#format-examples -- Cheers. Mark Lawrence

Re: Python equivalent to the "A" or "a" output conversions in C

2012-06-19 Thread Alexander Blinne
On 19.06.2012 18:23, Edward C. Jones wrote: > Consider the following line in C: >printf('%a\n', x); > where x is a float or double. This outputs a hexadecimal representation > of x. Can I do this in Python? Don't know why there is no format character %a or %A in python, but the conversion is

Re: Python equivalent to the "A" or "a" output conversions in C

2012-06-19 Thread Hemanth H.M
Are you looking for : >>> x=10 >>> hex(x) '0xa' >>> x=10.5 >>> float.hex(x) '0x1.5p+3' On Tue, Jun 19, 2012 at 9:53 PM, Edward C. Jones wrote: > hexadecimal -- *'I am what I am because of who we all are'* h3manth.com *-- Hemanth HM * -- http://mail.pyth

Python equivalent to the "A" or "a" output conversions in C

2012-06-19 Thread Edward C. Jones
Consider the following line in C: printf('%a\n', x); where x is a float or double. This outputs a hexadecimal representation of x. Can I do this in Python? -- http://mail.python.org/mailman/listinfo/python-list

Re: Tkinter binding question

2012-06-19 Thread Frederic Rentsch
Rick, Thank you for your thorough discussion. I tried your little program. Enter and leave work as expected. Pushing mouse buttons call leave-enter, exactly as it happened with my code. So that seems to be a default behavior. No big deal. Without the tracing messages it would go unnoticed. Releas

Re: Help On Paramiko

2012-06-19 Thread Michael Torrie
On 06/19/2012 12:28 AM, nikunj.badja...@emc.com wrote: > Howdy All, > > I am trying to use paramiko to automate logging in to remote unix machines > and executing some commands there. > When I normally do ssh from my linux machine (with Python 2.6) to this > machine a different '>' prompt comes.

Re: [BangPypers] Help On Paramiko

2012-06-19 Thread satyaakam goswami
> > o/p > ['UNIX shell commands cannot be executed using this account.\n'] > > Any suggestions? > > last time i had such a requirement it started just like you into writing something , then i did a quick web search before starting and found http://code.google.com/p/sshpt/ which served all our requ

Re: [Tutor] Pymongo Error

2012-06-19 Thread James Reynolds
On Tue, Jun 19, 2012 at 1:22 AM, Ranjith Kumar wrote: > Hi all, > I tried Django with Mongodb while running manage.py syncdb I endup with > this error > > note : it works fine with sqlite and mysql db > > (django-1.3)ranjith@ranjith:~/ > sandbox/python-box/hukkster-core-site/hukk$ ./manage.py sync

Re: Pythonic cross-platform GUI desingers à la Interface Builder (Re: what gui designer is everyone using)

2012-06-19 Thread Wolfgang Keller
> >> No matter how cool it may seem to create simple GUIs manually or to > >> write business letters using LaTeX: just try to persuade people to > >> move from Word to LaTeX for business letters... > > > > Good example. > > > > I have done nearly exactly this* - but it was only possible thanks > >

Re: Read STDIN as bytes rather than a string

2012-06-19 Thread Oscar Benjamin
On 19 June 2012 00:53, Jason Friedman wrote: > Which leads me to another question ... how can I debug these things? > > $ echo 'hello' | python3 -m pdb ~/my-input.py > > /home/jason/my-input.py(2)() > -> import sys > (Pdb) *** NameError: name 'hello' is not defined > -- > http://mail.python.org/m

Re: Is that safe to use ramdom.random() for key to encrypt?

2012-06-19 Thread Thomas Rachel
Am 18.06.2012 01:48 schrieb Paul Rubin: Steven D'Aprano writes: /dev/urandom isn't actually cryptographically secure; it promises not to block, even if it has insufficient entropy. But in your instance... Correct. /dev/random is meant to be used for long-lasting cryptographically-significant

Re: Checking compatibility of a script across Python versions automatically

2012-06-19 Thread Steven D'Aprano
On Mon, 18 Jun 2012 14:24:03 -0500, Andrew Berg wrote: > Are there any tools out there that will parse a script and tell me if it > is compatible with an arbitrary version of Python and highlight any > incompatibilities? I need to check a few of my scripts that target 3.2 > to see if I can make th

Re: Converting html character codes to utf-8 text

2012-06-19 Thread Peter Otten
Johann Spies wrote: > I am trying the following: > > Change data like this: > > Bien Donné : agri tourism > > to this: > > Bien Donné agri tourism > > I am using the 'unescape' function published on > http://effbot.org/zone/re-sub.htm#unescape-html but working through a file > I get the follo

Converting html character codes to utf-8 text

2012-06-19 Thread Johann Spies
I am trying the following: Change data like this: Bien Donné : agri tourism to this: Bien Donné agri tourism I am using the 'unescape' function published on http://effbot.org/zone/re-sub.htm#unescape-html but working through a file I get the following error: UnicodeDecodeError: 'ascii' codec

Re: Conditional decoration

2012-06-19 Thread Jean-Michel Pichavant
Roy Smith wrote: Is there any way to conditionally apply a decorator to a function? For example, in django, I want to be able to control, via a run-time config flag, if a view gets decorated with @login_required(). @login_required() def my_view(request): pass Hi, def my_view(request):

Re: "constant sharing" works differently in REPL than in script ?

2012-06-19 Thread Chris Angelico
On Tue, Jun 19, 2012 at 12:52 PM, wrote: > ...Python pre creates some integer constants to avoid a proliferation of > objects with the same value. > > I was interested in this and so I decided to try it out. > So that matched what I'd heard and then I did this to test the limits of it : > > And

Re: Conditional decoration

2012-06-19 Thread Gelonida N
On 06/19/2012 02:23 AM, Rob Williscroft wrote: Roy Smith wrote in news:jro9cj$b44$1...@panix2.panix.com in gmane.comp.python.general: Is there any way to conditionally apply a decorator to a function? For example, in django, I want to be able to control, via a run-time config flag, if a view ge

Re: Pymongo Error

2012-06-19 Thread Alan Gauld
On 19/06/12 06:22, Ranjith Kumar wrote: I tried Django with Mongodb while running manage.py syncdb I endup with this error You might be better off trying a mongo forum./mailing list since this list is for Python beginners and focuses on the Python language and std library. Django is not in t

Re: [BangPypers] Help On Paramiko

2012-06-19 Thread Guru
Refer this site you may get some useful information http://segfault.in/2010/03/paramiko-ssh-and-sftp-with-python/ On Tue, Jun 19, 2012 at 12:00 PM, Noufal Ibrahim wrote: > > Fabric is a library built on paramiko that gives you abstractions so > that you don't have to worry about things at such a