decimal to string conv

2009-02-27 Thread Aj
Hi all,

I am trying to convert a list to string.
example [80, 89,84,72,79,78,0] is my input. I could make it to just
[0x50,0x59,0x54,0x48,0x4F,0x4E,0x00].
but I wanted it to be like "PYTHON".
I couldnt even convert 0x50 to 'P'. Is there any library api available
to do this? it will be really helpful to me.
dont bang me if its already being asked. I just 'dived' into python
yesterday.

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


Re: decimal to string conv

2009-02-27 Thread Aj
On Feb 27, 10:58 am, Chris Rebert  wrote:
> On Fri, Feb 27, 2009 at 1:45 AM, Aj  wrote:
> > Hi all,
>
> > I am trying to convert a list to string.
> > example [80, 89,84,72,79,78,0] is my input. I could make it to just
> > [0x50,0x59,0x54,0x48,0x4F,0x4E,0x00].
> > but I wanted it to be like "PYTHON".
> > I couldnt even convert 0x50 to 'P'. Is there any library api available
> > to do this? it will be really helpful to me.
>
> lst = [80, 89,84,72,79,78,0]
> print ''.join(map(chr, lst[:-1]))
>
> Cheers,
> Chris
>
> --
> Follow the path of the Iguana...http://rebertia.com

wow... that was quick and it works perfect with my inputs.
thanx & have a nice day.

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


Acceesing python httplib2 over a network share in windows 7

2009-12-18 Thread aj
I am trying to run python from a network share on windows 7.
The network share is T:

>t:\python-2.6.1\python
Python 2.6.1 (r261:67517, Dec  4 2008, 16:51:00) [MSC v.1500 32
bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more
information.
>>> import httplib2
httplib2\__init__.py:29: DeprecationWarning: the md5 module is
deprecated; use hashlib instead
import md5
Traceback (most recent call last):
File "", line 1, in 
File "T:\python-2.6.1\lib\python2.6\site-packages
\httplib2\__init__.py", line 36, in 
import httplib
File "T:\python-2.6.1\lib\httplib.py", line 77, in 
import mimetools
File "T:\python-2.6.1\lib\mimetools.py", line 6, in 
import tempfile
File "T:\python-2.6.1\lib\tempfile.py", line 34, in 
from random import Random as _Random
File "T:\python-2.6.1\lib\random.py", line 871, in 
_inst = Random()
File "T:\python-2.6.1\lib\random.py", line 96, in __init__
self.seed(x)
File "T:\python-2.6.1\lib\random.py", line 110, in seed
a = long(_hexlify(_urandom(16)), 16)
WindowsError: [Error 127] The specified procedure could not be
found


When I copy python-2.6.1 to my local drive it works fine. It also
works fine on my windows XP machine using the same network share.
-- 
http://mail.python.org/mailman/listinfo/python-list


Accessing python from a network share in windows 7

2010-01-07 Thread aj
I access python from a network share. This works fine on XP but on
windows 7 it throws the following error:

Python 2.6.1 (r261:67517, Dec  4 2008, 16:51:00) [MSC v.1500 32 bit
(Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import random
Traceback (most recent call last):
  File "", line 1, in 
  File "t:\win32\python-2.6.1\lib\random.py", line 871, in 
_inst = Random()
  File "t:\win32\python-2.6.1\lib\random.py", line 96, in __init__
self.seed(x)
  File "t:\win32\python-2.6.1\lib\random.py", line 110, in seed
a = long(_hexlify(_urandom(16)), 16)
WindowsError: [Error 127] The specified procedure could not be found

Is there some security policy that I need to enable/disable to use
python from a network on windows 7?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Accessing python from a network share in windows 7

2010-01-07 Thread aj
On Jan 7, 3:51 pm, MRAB  wrote:
> aj wrote:
> > I access python from a network share. This works fine on XP but on
> > windows 7 it throws the following error:
>
> > Python 2.6.1 (r261:67517, Dec  4 2008, 16:51:00) [MSC v.1500 32 bit
> > (Intel)] on
> > win32
> > Type "help", "copyright", "credits" or "license" for more information.
> >>>> import random
> > Traceback (most recent call last):
> >   File "", line 1, in 
> >   File "t:\win32\python-2.6.1\lib\random.py", line 871, in 
> >     _inst = Random()
> >   File "t:\win32\python-2.6.1\lib\random.py", line 96, in __init__
> >     self.seed(x)
> >   File "t:\win32\python-2.6.1\lib\random.py", line 110, in seed
> >     a = long(_hexlify(_urandom(16)), 16)
> > WindowsError: [Error 127] The specified procedure could not be found
>
> > Is there some security policy that I need to enable/disable to use
> > python from a network on windows 7?
>
> Is it a problem with the share or with Windows 7? Does it work with
> Windows 7 when running a local copy of Python?

It works without any issue on win7 if I copy python to my local drive.
Also, accessing python from the same network share works fine on win
XP. So I am suspecting some security policy of win7 that is causing
problem while accessing it over a network share.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Accessing python from a network share in windows 7

2010-01-11 Thread aj
On Jan 9, 3:55 am, Anssi Saari  wrote:
> aj  writes:
> > I access python from a network share. This works fine on XP but on
> > windows 7 it throws the following error:
>
> > Python 2.6.1 (r261:67517, Dec  4 2008, 16:51:00) [MSC v.1500 32 bit
> > (Intel)] on
> > win32
> > Type "help", "copyright", "credits" or "license" for more information.
> >>>> import random
> > Traceback (most recent call last):
> >   File "", line 1, in 
> >   File "t:\win32\python-2.6.1\lib\random.py", line 871, in 
> >     _inst = Random()
> >   File "t:\win32\python-2.6.1\lib\random.py", line 96, in __init__
> >     self.seed(x)
> >   File "t:\win32\python-2.6.1\lib\random.py", line 110, in seed
> >     a = long(_hexlify(_urandom(16)), 16)
> > WindowsError: [Error 127] The specified procedure could not be found
>
> > Is there some security policy that I need to enable/disable to use
> > python from a network on windows 7?
>
> Well, there was just a complaint about this sort of thing on a local
> newsgroup here. Specifically, someone was trying to execute a Windows
> program from a share and every time Windows 7 pops up a warning window
> saying that the program is maybe from the evil interwebby and are you
> really sure you actually want to run it. So probably that's the
> command line version of same.
>
> Solution is apparently specifying your server to be in the local
> intranet, in IE's security settings. Apparently there is a non-working
> autodetection for what is a local intranet, so specifying the server
> IP address by hand in the advanced settigns is the working solution.

Thanks for the suggestion Anssi. I added the server in the local
intranet settings for IE, but that did not make any difference.
-- 
http://mail.python.org/mailman/listinfo/python-list


Tkinter Label alignment problem using OS 10.6

2010-07-30 Thread AJ
Dear users,

I have written a sample program that ran correctly with earlier than
Mac OS 10.6. The answer field Label does not align correctly. I
downloaded the latest Python 2.7 release but still did not solve the
problem.  Look for line "L4.place(relx=0.32,rely=0.56, anchor=W)"

#!/usr/bin/env python

from Tkinter import *
from tkMessageBox import *
import sys


win = Tk()
#win.tk.call('console', 'hide')
try:
win.tk.call('after','idle','console','hide')
except TclError:
pass
ScreenX = win.winfo_screenwidth()
ScreenY = win.winfo_screenheight()
ScreenX = (ScreenX/2) - 250
ScreenY = (ScreenY/2) - 200
win.geometry('500x300%+d%+d' %(ScreenX, ScreenY))
win.title("'Place' Geometry Test")
win.resizable(width=False, height=False)

FirstN  = StringVar()
SecondN = StringVar()
Answer  = StringVar()

Verd12 = ("Verdana","11")
Verd16 = ("Verdana","16")
Verd25 = ("Verdana","25")
Sys16  = ("System" ,"16")


#- AboutDialog 

class AboutDialog(Toplevel):

def __init__(self, parent):
Toplevel.__init__(self, parent)
self.configure(bg = 'white', borderwidth=3)
self.geometry('200x300%+d%+d' %(ScreenX, ScreenY))
self.title('About...')
self.resizable(height=FALSE, width=FALSE)
self.transient(parent)
self.grab_set()
self.protocol("WM_DELETE_WINDOW", self.OkToExit)
self.parent = parent
self.FillDialog()
self.Btn.focus_set()
self.bind('',self.OkToExit)
self.bind('',self.OkToExit)
self.bind('', Done)
self.bind('', Done)

self.wait_window()

def FillDialog(self):

self.AboutText = "\n\n\nPlace Geometry Test\n\nBy\n\nAmin
Aljuffali"
self.Lbl = Label(self, text=self.AboutText, font=Verd16, bg =
'white')
self.Lbl.pack(side=TOP)
self.Lb2 = Label(self, text="April 1, 2007", height = 1,
font=Verd12, bg = 'white')
self.Lb2.pack(side=TOP)
self.Lb3 = Label(self, text=" ", height = 3, font=Verd12, bg =
'white')
self.Lb3.pack(side=TOP)
self.Btn = Button(self, text='Done', font=Sys16, width=8,
height=1, command=self.OkToExit)
self.Btn.pack(side=TOP)
self.Lb4 = Label(self, text=" ", height = 3, font=Verd12, bg =
'white')
self.Lb4.pack(side=BOTTOM)
self.update()

def OkToExit(self, event=None):
self.destroy()

#--

def ShowDialog():
AboutDialog(win)

def done():
win.destroy()
win.quit

def Done(e):
win.destroy()
win.quit


def CheckAlfanumeric(x):

if x == '':
  return False
for ch in x:
  if ch not
in['.','-','+','0','1','2','3','4','5','6','7','8','9','e','E']:
return False
return True


def Multiply():

#global FirstN, SecondN, Answer

try:
  a = FirstN.get().strip()
  if not CheckAlfanumeric(a):
raise ValueError

  b = SecondN.get().strip()
  if not CheckAlfanumeric(b):
raise ValueError

  FirstN.set(a)
  SecondN.set(b)
  Answer.set(str(float(a) * float(b)))

except ValueError:
  showwarning("Warning...","Input Error!")

return

def MakeToplevelMenu(topwin):

top = Menu(topwin)
topwin.config(menu=top)

if sys.platform == 'darwin' and '.app' in sys.executable:
   application = Menu(top, name='apple')
   application.add_command(label='About...', command=ShowDialog,
underline=0)
   top.add_cascade(label='PlaceTest', menu=application,
underline=0)

fileMenu = Menu(top, tearoff=0)
fileMenu.add_command(label='Exit', command=done, underline=0)
top.add_cascade(label='File', menu=fileMenu, underline=0)

helpMenu = Menu(top, tearoff=0)
helpMenu.add_command(label='About...', command=ShowDialog,
underline=0)
top.add_cascade(label='Help', menu=helpMenu, underline=0)

return


MakeToplevelMenu(win)

L1 = Label(win, text='Multiply Two Numbers', font=Verd25, bg =
'white')
L2 = Label(win, text='First Number:', font=Verd16, bg = 'white')
L3 = Label(win, text='Second Number:', font=Verd16, bg = 'white')
L4 = Label(win,  text='', textvariable=Answer, font=Sys16, bg =
'white', bd=1, width=20, height=1, anchor=W, relief=SOLID)
L5 = Label(win,  text='Written by Amin Aljuffali', font=Verd12,padx=2,
bg = 'white', anchor=W, relief=FLAT)
B1 = Button(win, text='Multiply', font=Sys16, width=19, height=1,
command=Multiply)
B2 = Button(win, text='Quit', font=Sys16, width=19, height=1,
command=done)
F1 = Frame(win, relief=FLAT, bd=0, bg='#336699')
F2 = Frame(win, relief=FLAT, bd=0, bg='#336699')
F3 = Frame(win, relief=FLAT, bd=0, bg='#336699')

E1 = Entry(win, textvariable=FirstN, relief=SOLID, font=Sys16, bg =
'white',bd=1)
E2 = Entry(win, textvariable=SecondN, relief=SOLID, font=Sys16, bg =
'white', bd=1)

win.bind('', Done)
win.bind('', Done)

F1.place(relx=0.0,rely=0.01, anchor=NW, width=600, height=5)
L1.place(relx=0.5,rely=0.09, anchor=CENTER)
F2.place(r

Re: Tkinter Label alignment problem using OS 10.6

2010-07-30 Thread AJ
On Jul 30, 5:07 pm, rantingrick  wrote:
> On Jul 30, 6:52 pm, AJ  wrote:
>
> > Dear users,
>
> > I have written a sample program that ran correctly with earlier than
> > Mac OS 10.6. The answer field Label does not align correctly. I
> > downloaded the latest Python 2.7 release but still did not solve the
> > problem.  Look for line "L4.place(relx=0.32,rely=0.56, anchor=W)"
>
> DO YOURSELF A HUGE FAVOR AJ... Learn how to use the "pack" and "grid"
> geometry managers available in Tkinter before it's too late. Well,
> unless of course your a sadist. In that case just ignore my post
> completely. 8^O
>
> http://effbot.org/tkinterbook/tkinter-index.htm#introduction

I know the pack and grid. They do not allow me to position my widget
the way I want.
You have to go back to first grade and relearn the phrase “If you have
nothing nice to say do not say anything at all”.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tkinter Label alignment problem using OS 10.6

2010-07-31 Thread AJ
On Jul 31, 12:55 am, Peter Otten <__pete...@web.de> wrote:
> AJ wrote:
> > I have written a sample program that ran correctly with earlier than
> > Mac OS 10.6. The answer field Label does not align correctly. I
> > downloaded the latest Python 2.7 release but still did not solve the
> > problem.  Look for line "L4.place(relx=0.32,rely=0.56, anchor=W)"
>
> The underlying Tcl/Tk is more likely to be the cause of your problem, so
> you'd have to look at that.
>
> I'm on Linux with Python2.6 and Tcl/Tk 8.5, and don't see a misalignment.
>
> Stab in the dark: try creating L4 with explicit padding:
>
> L4 = Label(..., padx=0)
>
> Peter
>
> PS: Rantingrick is right; you should use one of the other geometry managers

Thank you Peter. I’ve tried the padding but it does not solve the
issue.  It only does it with Mac OS 10.6. it works fine with Windows
and Linux and earlier Mac OS than 10.6.
To write professional GUI one needs to have full control over the
placement of the Widgets. Some programmers have switched to wxPython
because of this issue and I am trying not to.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tkinter Label alignment problem using OS 10.6

2010-07-31 Thread AJ
On Jul 31, 8:04 am, r  wrote:
> On Jul 31, 2:55 am, Peter Otten <__pete...@web.de> wrote:
>
> > PS: Rantingrick is right; you should use one of the other geometry managers
>
> Incidentally I was actually writing a version of the OP's script using
> the grid manager when i found his nasty response. So I think i'll just
> keep it for me self now. Good luck AJ. ;-)

Thank you. Do not let it get to you. There are some people like that.
If you have an idea or need help do not be distracted by this. Just
post it and hope someone can help you. This is more beneficial for you
and others who have the same questions and some day you may be helping
others. Cheers!
-- 
http://mail.python.org/mailman/listinfo/python-list


make install DESTDIR

2010-08-20 Thread aj
I am trying to install python with make install DESTDIR=/home/blah

./python -E ./setup.py install \
--prefix=/ \
--install-scripts=//bin \
--install-platlib=//lib/python2.6/lib-dynload \
--root=//home/blah
running install
running build
running build_ext
INFO: Can't locate Tcl/Tk libs and/or headers

Failed to find the necessary bits to build these modules:
_tkinter   bsddb185   dl
imageopsunaudiodev
To find the necessary bits, look in setup.py in detect_modules() for
the module's name.

running build_scripts
running install_lib
creating /lib/python2.6
error: could not create '/lib/python2.6': Permission denied
make: *** [sharedinstall] Error 1
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: make install DESTDIR

2010-08-20 Thread aj
On Aug 20, 4:39 pm, Thomas Jollans  wrote:
> On Saturday 21 August 2010, it occurred to aj to exclaim:
>
> > I am trying to install python with make install DESTDIR=/home/blah
>
> >                 --prefix=/
>
> ...
>
> > creating /lib/python2.6
> > error: could not create '/lib/python2.6': Permission denied
> > make: *** [sharedinstall] Error 1
>
> Obviously, the flags you specified didn't have the effect you intended.
>
>   --prefix=$HOME
>
> should do the trick.

The whole point of DESTDIR is that it should be prepended to all
installed paths, but the binaries should not contain any references to
it.DESTDIR is commonly used by packagers, for example, to allow
installation without superuser privileges.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: make install DESTDIR

2010-08-23 Thread aj
Thanks for reply Thomas. I am running make install DESTDIR=/home/foo/
bar.
Martin- Asking for help :)

On Aug 21, 4:43 am, "Martin v. Loewis"  wrote:
> > The whole point of DESTDIR is that it should be prepended to all
> > installed paths, but the binaries should not contain any references to
> > it.DESTDIR is commonly used by packagers, for example, to allow
> > installation without superuser privileges.
>
> So what is the point of your messages? Do you want to report a problem?
> Are you asking for help? Do you want to vent frustration?
>
> Regards,
> Martin

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


Re: make install DESTDIR

2010-08-23 Thread aj
On Aug 23, 2:23 pm, "Martin v. Loewis"  wrote:
> > Martin- Asking for help :)
>
> Ok. Please try the patch below.
>
> If this works, please make a bug report.
>
> Regards,
> Martin
>
> Index: Lib/distutils/util.py
> ===
> --- Lib/distutils/util.py       (Revision 84197)
> +++ Lib/distutils/util.py       (Arbeitskopie)
> @@ -220,7 +220,7 @@
>          if not os.path.isabs(pathname):
>              return os.path.join(new_root, pathname)
>          else:
> -            return os.path.join(new_root, pathname[1:])
> +            return os.path.join(new_root, pathname.lstrip('/'))
>
>      elif os.name == 'nt':
>          (drive, path) = os.path.splitdrive(pathname)

Thanks Martin. That seems to work. I will file a bug report. Also, can
you describe what the problem was?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: make install DESTDIR

2010-08-24 Thread aj
On Aug 23, 10:52 pm, "Martin v. Loewis"  wrote:
> > Thanks Martin. That seems to work. I will file a bug report. Also, can
> > you describe what the problem was?
>
> If you have / as the prefix, you get two leading slashes, e.g. for
> //lib/python2.x. Any other prefix would have given you only a single
> slash: e.g. if it had been /usr, then you end up with /usr/lib/python2.x.
>
> Now, the code strips the first character to make it a relative path name
> (so that join can be used), which fails to work correctly if there are
> two leading slashes.
>
> HTH,
> Martin
Thanks a lot for the help Martin. I have created 
http://bugs.python.org/issue9674
-- 
http://mail.python.org/mailman/listinfo/python-list


error when compiling source on linux

2009-07-16 Thread aj
when I try to compile Python 2.6 from source code on ubuntu, I get the
message
/usr/bin/ld: cannot open output file python: Is a directory
collect2: ld returned 1 exit status
make: *** [python] Error 1
PLEASE HELP!
-- 
http://mail.python.org/mailman/listinfo/python-list


[job] multiple openings for CS, CE, EE, IT majors / graduates

2011-08-03 Thread AJ ONeal
I know of some job openings. Contact me off list for more details.


The positions are full-time (or at least 30hrs / week) paid internships that
should lead to a full-time salaried position in near future.


If a *mix of any* of the bullet points below *describes you* or *someone you
know*, please ask me some questions, send me a resume, and I'll get you in
touch with some great people who need you!


*All great candidates*

   - have taken their education into their own hands to some degree
   - learn quickly
   - have beyond-the-classroom experience / personal projects
   - know how to leverage tools and people in their circle (forums, interest
   groups, friends) to find answers to questions
   - are familiar with *nix and know their way around with find, grep, vim
   (or emacs)




*Event-driven Application Developer*

   - could write a basic evented messaging queueing and retrieval service in
   about a week

   - can solve fizzbuzz in less than an hour
   - has written a simple chat server
   - knows the difference between a markup language and an object notation

   - is familiar with one of node.js, python / twisted, ruby / eventmachine,
   go, erlang
   - has used a web framework of some sort
   - has used C and written a queue of some sort
   - enjoys regex

   - has a good understanding of http and general networking concepts
   - has used wireshark to examine http and tcp traffic
   - has written a native mobile app (iOS, Android)




*Gadget Engineer*

   - could build a rechargeable battery-powered usb hub in about a week

   - could reverse engineer a cheap usb hub from e-bay in about a day
   - could build a pringles cantenna in about a day


   - has used C and written a queue of some sort
   - can write object-oriented C (as if it were a programming language)


   - has played with Arduino, Bug, Beagle, Panda, or some other sort of
   project board

   - Envies those who own a Fluke multimeter (or owns one)




*HTML5 Web App Developer*

   - could write a basic client-side timesheet application in about a week

   - has a good handle on JavaScript
   - knows how to use CSS selectors
   - knows the difference between a markup language and an object notation
   - knows the difference (or relationship) between HTML and the DOM


   - can solve fizzbuzz in less than an hour
   - has written a simple chat server
   - can draw a graph on canvas
   - enjoys regex

   - has worked with APIs such as Google Apps, facebook, twitter, etc
   - has a good understanding of http and general networking concepts
   - has used wireshark or firebug to examine http traffic
   - has written a native mobile app (iOS, Android)




*Linux Techie++*

   - could set up a VPS with nginx, gitosis, git pull hooks, and
   reverse-proxied apps in about a week

   - has built a kernel
   - has built an out-of-tree kernel module

   - can use bash almost as if were a programming language (but has the good
   sense not to)
   - can write object-oriented C (as if it were a programming language)
   - enjoys regex

   - has used C and written a queue of some sort
   - has used wireshark to examine traffic
   - is familiar with one of node.js, python / twisted, ruby / eventmachine,
   go, erlang




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


Presentation: Offline (iPhone) Web Apps - Thurs 7pm in Lindon @ CORDA

2011-03-02 Thread AJ ONeal
Sorry for spamming you all... or not actually. I'm glad.


We're going to have an awesome meeting tomorrow at CORDA with two
presentations about something all your people using web frameworks are
hopefully interested in:

Offline Web Apps and IndexDB

AND

Offline Web Apps on iPhone / Android / MIDs


Bring a laptop and an Android, iPhone, iPad, whatever, and let's have an
awesome meeting tomorrow!

7pm - 9pm
CORDA Technologies, Inc.
350 South 400 West, Suite 100
Lindon, UT 84042

AJ ONeal
(317) 426-6525
-- 
http://mail.python.org/mailman/listinfo/python-list


Empty string is False right?

2009-01-31 Thread AJ Ostergaard

Hello,

First post so bear with me if I'm being a numpty ...

Is it me or is there something slightly counter intuitive and thus not  
so pythonesque about this:


>>> s = ''
>>> if s: True
... else: False
...
False
>>> s and eval(s)
''
>>>

Regards,
AJ

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


Re: Empty string is False right?

2009-01-31 Thread AJ Ostergaard

Hi Ralf,

Thanks for that but why:

>>> '' and True
''

Surely that should be False?!?

Regards,
AJ


On 31 Jan 2009, at 12:12, Ralf Schoenian wrote:


AJ Ostergaard wrote:

Hello,
First post so bear with me if I'm being a numpty ...
Is it me or is there something slightly counter intuitive and thus  
not so pythonesque about this:

>>> s = ''
>>> if s: True
.... else: False

False
>>> s and eval(s)
''
>>>
Regards,
AJ


Hi,

yes, the following evaluates to False:
empty String: ''
empty list: []
empty tuple: ()
empty dict: {}
0, None
and False of course

Regards,
Ralf


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


Re: Empty string is False right?

2009-01-31 Thread AJ Ostergaard
I'm not suggesting it's not operating as advertised - I'm suggesting  
the 'advertising' is slightly sguiffy if you catch my drift. I guess  
it's just me that finds it slightly counter intuitive. Surely  
intuitively the expression is "and" and therefore should always return  
a boolean?


I'll shut up now. ;)

AJ


On 31 Jan 2009, at 12:27, Vlastimil Brom wrote:


2009/1/31 AJ Ostergaard :

Hi Ralf,

Thanks for that but why:


'' and True

''

Surely that should be False?!?

Regards,
AJ



see the docs:
http://docs.python.org/reference/expressions.html#boolean-operations

"The expression x and y first evaluates x; if x is false, its value is
returned; otherwise, y is evaluated and the resulting value is
returned."

hth,
 vbr


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


Re: Python-list Digest, Vol 64, Issue 697

2009-01-31 Thread AJ Ostergaard

AJ Ostergaard wrote:
I'm not suggesting it's not operating as advertised - I'm  
suggesting the

'advertising' is slightly sguiffy if you catch my drift. I guess it's
just me that finds it slightly counter intuitive. Surely  
intuitively the

expression is "and" and therefore should always return a boolean?

You might think so, and it wouldn't be an entirely unreasonable  
thought,

but in practice it makes a lot of sense to retain the original value
where possible.

The fact is that any left-hand operand that evaluates to false in a
Boolean context can be used as it stands rather than being converted  
to

Boolean first. So the conversion is essentially useless processing.


That's what I've figured out during the course of the day.

Thanks for listening one and all! :)

Regards,
AJ

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


Python inside C++

2009-04-13 Thread AJ Mayorga
Hello all,

 

I am looking for a way  to statically compile pythonxx.dll into my C++
application, so that I can use It as an internal scripting language and
either run the native python code or take an ELF from py2exe/pyinstaller and
run that.

The machines that will have my C++ app running on them do not have python
and I cannot install it as part of my application. Any Ideas?

 

AJ

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


RE: Imports in python are static, any solution?

2009-04-13 Thread AJ Mayorga
For something like this I generally create a superclass to hold
configuration variables that will change overtime, doing that will save you
from insanity.

Class configVar:

#set initial values
Def __init__(self):
Self.A = 5
Self.B = 10
Self.C = 20


Class myMath(configVars):
def __init__(self):
pass

def SubAandB(self):
return self.A - self.B

def AddCandB(self):
return self.C + self.B

def MultiplyXbyA(self, x):
return self.A * x


m = myMath()
X = m.SubAandB()
Y = m.AddCandB()
Z = m.MultiplyXbyA(32)

Keeps your vars in a safer easier to handle, debug, and change kinda way
Good luck

AJ

-Original Message-
From: python-list-bounces+aj=xernova@python.org
[mailto:python-list-bounces+aj=xernova@python.org] On Behalf Of David
Stanek
Sent: Monday, April 13, 2009 12:12 PM
To: Ravi
Cc: python-list@python.org
Subject: Re: Imports in python are static, any solution?

On Mon, Apr 13, 2009 at 11:59 AM, Ravi  wrote:
> foo.py :
>
>    i = 10
>
>   def fi():
>      global i
>      i = 99
>
> bar.py :
>
>    import foo
>    from foo import i
>
>    print i, foo.i
>    foo.fi()
>    print i, foo.i
>
> This is problematic. Well I want i to change with foo.fi() .

Why not only import foo and using foo.i? In fi() when you set i = 99
you are creating a new object called i in foo's namespace.


-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek
--
http://mail.python.org/mailman/listinfo/python-list

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


Django (and Pylons) HTML Form Objects & Arrays

2010-01-13 Thread AJ ONeal
Do Django and Pylons use templates which map forms in the php / ruby manner
(generally speaking)?











AJ ONeal
(317) 426-6525
-- 
http://mail.python.org/mailman/listinfo/python-list


Python SSL Client Authentication

2009-10-02 Thread AJ Mayorga
I have been able to use the ssl module in Python 2.6 to setup a server that
requires

The client to authenticate via an x509 certificates, but I want to be able
to override the client

Authentication process or catch the exception so that I can do redirects
etc. if the client authentication

Fails. Does anyone have a code snippet for this.

 

AJM

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


MediaTags - exporting m4a, id3, exiv, etc as JSON (YAML)

2010-11-25 Thread AJ ONeal
I'm sponsoring the development of cross-platform (C/C++) utilities for
extracting a variety of media meta-data as JSON, including stream
checksums and stream meta-data.

git://github.com/coolaj86/mtags.git


I'd like to get support for developing this, and I'm interested in the
opinions
of others who would use these tools.

http://pledgie.com/campaigns/14039


The m4atags utility is now complete.
Here's an example of the usage / output:

http://coolaj86.info/articles/example-of-verbose-output-from-mediatags.html

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


MediaTags - exporting m4a, id3, exiv, etc as JSON

2010-11-25 Thread AJ ONeal
I'm sponsoring the development of cross-platform (C/C++) utilities for
extracting a variety of media meta-data as JSON, including stream
checksums and stream meta-data.

git://github.com/coolaj86/mtags.git


I'd like to get support for developing this, and I'm interested in the
opinions
of others who would use these tools.

http://pledgie.com/campaigns/14039


The m4atags utility is now complete.
Here's an example of the usage / output:

http://coolaj86.info/articles/example-of-verbose-output-from-mediatags.html

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


Stream Audio to Web Clients

2010-09-16 Thread AJ ONeal
I'm looking for an example (perhaps with red5) for this scenario:

1. I install some server tools on my ubuntu box
2. I place an mp3 and an m4a in a special location
3. I click a play button on a web page and both songs play in random order

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


Re: Synchronise annotations -> docstring

2024-09-15 Thread AJ via Python-list

On 9/4/24 00:21, r...@zedat.fu-berlin.de wrote:

Albert-Jan Roskam  wrote or quoted:

Are there any tools that check whether type annotations and Numpydoc
strings are consistent?


 According to one webpage, the "sphinx-autodoc-typehints" extension
 lets you roll with Python 3 annotations for documenting the types
 of arguments and return values of functions. 


 So, you'd have a "single source of truth" again to keep everything
 chill and straightforward.





Thanks, I'll have a look. I'm currently using pdoc (or was it pdoc3?) but I
could go back to Sphinx. I like Markdown better than restructuredText,
though.
--
https://mail.python.org/mailman/listinfo/python-list