simple problem with jpype on WindowsXP

2011-03-26 Thread curtin
Hi, I've got some kind of install problem with jpype ... It should just work, but throws a dialog exception, that doesn't give a stack trace so not very helpful. This should be a simple install issue, but I've searched and haven't seen any thing import jpype p = jpype.getDefaultJVMPath() jpype.s

Re: Simple Problem but tough for me if i want it in linear time

2010-08-30 Thread Aahz
In article , Tim Chase wrote: >On 08/18/10 21:47, Steven D'Aprano wrote: >> >> Frankly, I think the OP doesn't really know what he wants, other than >> premature optimization. It's amazing how popular that is :) > >You see, the trick to prematurely optimizing is to have a good >algorithm for pre

Re: Simple Problem but tough for me if i want it in linear time

2010-08-18 Thread Tim Chase
On 08/18/10 21:47, Steven D'Aprano wrote: Frankly, I think the OP doesn't really know what he wants, other than premature optimization. It's amazing how popular that is :) You see, the trick to prematurely optimizing is to have a good algorithm for prematurely optimizing...the real question th

Re: Simple Problem but tough for me if i want it in linear time

2010-08-18 Thread Steven D'Aprano
On Wed, 18 Aug 2010 16:03:58 +0200, Frederic Rentsch wrote: > On Mon, 2010-08-16 at 23:17 +, Steven D'Aprano wrote: >> On Mon, 16 Aug 2010 20:40:52 +0200, Frederic Rentsch wrote: >> >> > How about >> > >> [obj for obj in dataList if obj.number == 100] >> > >> > That should create a lis

Re: Simple Problem but tough for me if i want it in linear time

2010-08-18 Thread Frederic Rentsch
On Mon, 2010-08-16 at 23:17 +, Steven D'Aprano wrote: > On Mon, 16 Aug 2010 20:40:52 +0200, Frederic Rentsch wrote: > > > How about > > > [obj for obj in dataList if obj.number == 100] > > > > That should create a list of all objects whose .number is 100. No need > > to cycle through a

Re: Simple Problem but tough for me if i want it in linear time

2010-08-16 Thread Steven D'Aprano
On Mon, 16 Aug 2010 20:40:52 +0200, Frederic Rentsch wrote: > How about > [obj for obj in dataList if obj.number == 100] > > That should create a list of all objects whose .number is 100. No need > to cycle through a loop. What do you think the list comprehension does, if not cycle throug

Re: Simple Problem but tough for me if i want it in linear time

2010-08-16 Thread Frederic Rentsch
On Sun, 2010-08-15 at 15:14 +0200, Peter Otten wrote: > ChrisChia wrote: > > > dataList = [a, b, c, ...] > > where a, b, c are objects of a Class X. > > In Class X, it contains self.name and self.number > > > > If i wish to test whether a number (let's say 100) appears in one of > > the object, a

Re: Simple Problem but tough for me if i want it in linear time

2010-08-15 Thread Steven D'Aprano
On Sun, 15 Aug 2010 05:47:04 -0700, ChrisChia wrote: > dataList = [a, b, c, ...] > where a, b, c are objects of a Class X. In Class X, it contains > self.name and self.number > > If i wish to test whether a number (let's say 100) appears in one of the > object, and return that object, > is that o

Re: Simple Problem but tough for me if i want it in linear time

2010-08-15 Thread MRAB
ChrisChia wrote: dataList = [a, b, c, ...] where a, b, c are objects of a Class X. In Class X, it contains self.name and self.number If i wish to test whether a number (let's say 100) appears in one of the object, and return that object, is that only fast way of solving this problem without iter

Re: Simple Problem but tough for me if i want it in linear time

2010-08-15 Thread Peter Otten
ChrisChia wrote: > dataList = [a, b, c, ...] > where a, b, c are objects of a Class X. > In Class X, it contains self.name and self.number > > If i wish to test whether a number (let's say 100) appears in one of > the object, and return that object, > is that only fast way of solving this problem

Simple Problem but tough for me if i want it in linear time

2010-08-15 Thread ChrisChia
dataList = [a, b, c, ...] where a, b, c are objects of a Class X. In Class X, it contains self.name and self.number If i wish to test whether a number (let's say 100) appears in one of the object, and return that object, is that only fast way of solving this problem without iterating through every

Re: simple problem with lists I am just forgetting

2008-07-31 Thread Paul McGuire
On Jul 31, 2:51 pm, Alexnb <[EMAIL PROTECTED]> wrote: > Lets say we have this list: > > funlist = ['a', 'b', 'c'] > > and lets say I do this: > > if funlist[4]: >     print funlist[4] > > I will get the exception "list index out of range" > > How can I test if the list item is empty without getting

Re: simple problem with lists I am just forgetting

2008-07-31 Thread bearophileHUGS
Alexnb: > How can I test if the list item is empty without getting that exception? In Python such list cell isn't empty, it's absent. So you can use len(somelist) to see how much long the list is before accessing its items. Often you can iterate on the list with a for, so you don't need to care of

simple problem with lists I am just forgetting

2008-07-31 Thread Alexnb
-- View this message in context: http://www.nabble.com/simple-problem-with-lists-I-am-just-forgetting-tp18762181p18762181.html Sent from the Python - python-list mailing list archive at Nabble.com. -- http://mail.python.org/mailman/listinfo/python-list

Re: dynamically created names / simple problem

2008-03-25 Thread John Nagle
Robert Bossy wrote: > Jules Stevenson wrote: >> >> Hello all, >> >> I'm fairly green to python and programming, so please go gently. The >> following code >> >> for display in secondary: >> >> self.("so_active_"+display) = wx.CheckBox(self.so_panel, -1, >> "checkbox_2") >> >> Errors, because of t

RE: dynamically created names / simple problem

2008-03-25 Thread Jules Stevenson
Brilliant. Thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: dynamically created names / simple problem

2008-03-25 Thread Robert Bossy
Robert Bossy wrote: > Jules Stevenson wrote: > >> Hello all, >> >> I'm fairly green to python and programming, so please go gently. The >> following code >> >> for display in secondary: >> >> self.("so_active_"+display) = wx.CheckBox(self.so_panel, -1, "checkbox_2") >> >> Errors, because of the

Re: dynamically created names / simple problem

2008-03-25 Thread Robert Bossy
Jules Stevenson wrote: > > Hello all, > > I'm fairly green to python and programming, so please go gently. The > following code > > for display in secondary: > > self.("so_active_"+display) = wx.CheckBox(self.so_panel, -1, "checkbox_2") > > Errors, because of the apparent nastyness at the beginnin

dynamically created names / simple problem

2008-03-25 Thread Jules Stevenson
Hello all, I'm fairly green to python and programming, so please go gently. The following code for display in secondary: self.("so_active_"+display) = wx.CheckBox(self.so_panel, -1, "checkbox_2") Errors, because of the apparent nastyness at the beginning. What I'm trying to do is

Re: Simple problem with GUI!!

2006-10-27 Thread Fredrik Lundh
"mohan" wrote: > At the end I had to close down my entire python compiler. I am using > Python compiler with following specs in Windows XP OS. > > Pythonwin - Python IDE and GUI Framework for Windows. > PythonWin 2.2.1 (#34, Feb 25 2003, 11:29:09) [MSC 32 bit (Intel)] on > win32. > Portions Copyri

Simple problem with GUI!!

2006-10-27 Thread mohan
Hello Guys, I am a beginner with Python programming and would like to implement some GUI functionalities along with my main work. So I was trying to implement one basic program (available from books). Here is the code, import Tkinter TopLevelWindowObj = Tkinter.Tk()

Re: Format a number as currency! I can't find any help on this simple problem.

2006-10-17 Thread Peter Otten
jr wrote: >> >>> import locale >> >>> locale.setlocale(locale.LC_ALL, 'English_United States.1252') >> 'English_United States.1252' > Just tried the first 2 commands on win XP, Python 2.5 under Idle. > An Error is raised: "unsupported locale setting" (lib/locale.py in > setlocale, line 476). > Ac

Re: Format a number as currency! I can't find any help on this simple problem.

2006-10-17 Thread Jerry
Replace the conv function call with locale.localeconv. -- Jerry -- http://mail.python.org/mailman/listinfo/python-list

Re: Format a number as currency! I can't find any help on this simple problem.

2006-10-17 Thread jr
Hi, Bernard. Just tried the first 2 commands on win XP, Python 2.5 under Idle. An Error is raised: "unsupported locale setting" (lib/locale.py in setlocale, line 476). Actually I get the error also under Python 2.4.3 Any idea what I'm missing? Thanks in advance. Jürgen Bernard wrote: > >>> import l

Re: Format a number as currency! I can't find any help on this simple problem.

2006-10-10 Thread Ben Finney
Richard Kessler <[EMAIL PROTECTED]> writes: > I am relatively new to Python. Love it, but I find things that I > can do easily in .NET and cannot find a way to do in Python. I need > to format a number as currency, for example 12343.56 to $12,343.56. > > In C# all I need to do is decimal x = 1234

Re: Format a number as currency! I can't find any help on this simple problem.

2006-10-10 Thread Bernard
>>> import locale >>> locale.setlocale(locale.LC_ALL, 'English_United States.1252') 'English_United States.1252' >>> conv = locale.localeconv() >>> x = 1234567.8 >>> locale.format("%d", x, grouping=True) '1,234,567' >>> locale.format("%s%.*f", (conv['currency_symbol'], conv['int_frac_digits'], >>>

Format a number as currency! I can't find any help on this simple problem.

2006-10-10 Thread Richard Kessler
I am relatively new to Python. Love it, but I find things that I can do easily in .NET and cannot find a way to do in Python. I need to format a number as currency, for example 12343.56 to $12,343.56. In C# all I need to do is decimal x = 12343.56 then x.ToString("$###,###.00"); I cannot find

Re: pysqlite - simple problem

2006-09-03 Thread rdrink
Dennis Lee Bieber wrote: > That is probably the worst way to "fix" the problem -- as in the > future, you may end up trying that method for something that may need to > be quoted or escaped. > > cur.execute(template, (arg1,) ) > > allows the DB-API spec to properly convert the argument

Re: pysqlite - simple problem

2006-09-01 Thread Fredrik Lundh
rdrink wrote: > And yes I should prolly move to pysqlite2, but for now I was able to > fix it this way... > num = 200 > mess = "INSERT INTO foo (id) VALUES (%s)" % num > cur.execute(mess) > > ... don't know why I didn't think of that last (oh wait, Yes I do... > because 'last night' was actually

Re: pysqlite - simple problem

2006-09-01 Thread rdrink
Thanks everyone! But... RTFM? Ouch. It's not like I don't know what I'm doing :-( ... rather, that I *am* using the older sqlite module > print sqlite.paramstyle = pyformat > print sqlite.version = 1.0.1 which does not support the qmark sytax. (and I fell victim of someone elses tutor

Re: pysqlite - simple problem

2006-09-01 Thread John Machin
Fredrik Lundh wrote: > John Machin wrote: > >> So this has to be something stupidly simple... but for the life of me I > >> can't see it. > > > > With the '?' paramstyle, the 2nd arg to cursor.execute() should be a > > *sequence* (typically a tuple) of the values that you are inserting. > > > > Tt

Re: pysqlite - simple problem

2006-09-01 Thread Fredrik Lundh
John Machin wrote: >> So this has to be something stupidly simple... but for the life of me I >> can't see it. > > With the '?' paramstyle, the 2nd arg to cursor.execute() should be a > *sequence* (typically a tuple) of the values that you are inserting. > > Tty this: > cur.execute("INSERT INTO foo

Re: pysqlite - simple problem

2006-09-01 Thread John Machin
rdrink wrote: > I am just getting into pysqlite (with a fair amount of Python and MySQL > experience behind me) and have coded a simple test case to try to get > the hang of things... > yet have run into a 'stock simple' problem... > > I can create a database 't

Re: pysqlite - simple problem

2006-09-01 Thread Fredrik Lundh
"rdrink" <[EMAIL PROTECTED]> wrote: >I am just getting into pysqlite (with a fair amount of Python and MySQL > experience behind me) and have coded a simple test case to try to get > the hang of things... > > yet have run into a 'stock simple' problem..

Re: pysqlite - simple problem

2006-09-01 Thread Gerold Penz
rdrink schrieb: > num = 200 > cur.execute("INSERT INTO foo (id) VALUES (?)", num) Hi! ``num`` must be an iterable object (tuple, list, ...). num = (200,) cur.execute("INSERT INTO foo (id) VALUES (?)", num) Regards, Gerold :-) -- __

pysqlite - simple problem

2006-09-01 Thread rdrink
I am just getting into pysqlite (with a fair amount of Python and MySQL experience behind me) and have coded a simple test case to try to get the hang of things... yet have run into a 'stock simple' problem... I can create a database 'test.db', add a table 'foo' (

Python, VB math simple problem

2006-03-31 Thread Mr X
Hi looking for help with what should be a fairly simple Python problem, relating to VB inter-operability. Got a great response from a fellow named Matt at [EMAIL PROTECTED], pointed me in some good directions - some areas, concerns still foggy on, the below thread is included any feedbac

Python, VB math simple problem

2006-03-31 Thread Mr X
Hi looking for help with what should be a fairly simple Python problem, relating to VB inter-operability. Got a great response from a fellow named Matt at [EMAIL PROTECTED], pointed me in some good directions - some areas, concerns still foggy on, the below thread is included any feedbac

Re: simple problem with os.rename() parameters - path with spaces

2005-09-10 Thread Peter Hansen
Tom wrote: > Peter Hansen wrote: >> Where do you think those double quotation marks came from? What >> happens if you try the following instead of using the variables you >> were trying to use? >> >> os.rename("e:\\music\\Joni Mitchell\\ogg-8", >> "e:\\music.ogg\\Joni Mitchell\\ogg-8") >> >

Re: simple problem with os.rename() parameters - path with spaces

2005-09-10 Thread Tom
Peter Hansen wrote: > Tom wrote: > >>Drive E: is removable, so I was careful to verify that that was a factor >>in the problem. >> >>Yes, I can do the same renaming, with the same drive, at the command line. >> >>I think I put the emphasis in the wrong place in my question. This >>isn't really

Re: simple problem with os.rename() parameters - path with spaces

2005-09-10 Thread Peter Hansen
Tom wrote: > Drive E: is removable, so I was careful to verify that that was a factor > in the problem. > > Yes, I can do the same renaming, with the same drive, at the command line. > > I think I put the emphasis in the wrong place in my question. This > isn't really about os.rename(). It is

Re: simple problem with os.rename() parameters - path with spaces

2005-09-10 Thread Tom
Yes, I am sure about those things. I've tried shutil.move and got the same result. Forward slash? I'll give that a try and report back here if it works. Thanks, Tom. Larry Bates wrote: > Are you sure the source directory exists and you > have rights to rename it? Because the rename works > for

Re: simple problem with os.rename() parameters - path with spaces

2005-09-10 Thread Tom
Peter Hansen wrote: > Tom wrote: > >>I'm having a problem using a path with spaces as a parameter to >>os.rename() in a program on WinXP. >> >>This works fine at the command line (where the folder "c:\aa bb" exists) >> >> > os.rename( "c\aa bb", "c:\cc dd" ); >> > >> >>But, I can't get it to work

Re: simple problem with os.rename() parameters - path with spaces

2005-09-09 Thread Peter Hansen
Tom wrote: > I'm having a problem using a path with spaces as a parameter to > os.rename() in a program on WinXP. > > This works fine at the command line (where the folder "c:\aa bb" exists) > > > os.rename( "c\aa bb", "c:\cc dd" ); > > > > But, I can't get it to work in my program, eg. > >

Re: simple problem with os.rename() parameters - path with spaces

2005-09-09 Thread Larry Bates
Are you sure the source directory exists and you have rights to rename it? Because the rename works for me. But you may want to look at shutil.move and/or use forward slashes (they work under Windows) -Larry Bates Tom wrote: > I'm having a problem using a path with spaces as a parameter to > o

simple problem with os.rename() parameters - path with spaces

2005-09-09 Thread Tom
I'm having a problem using a path with spaces as a parameter to os.rename() in a program on WinXP. This works fine at the command line (where the folder "c:\aa bb" exists) > os.rename( "c\aa bb", "c:\cc dd" ); > But, I can't get it to work in my program, eg. print SrcDir print NewDir os.rena

Re: Simple Problem

2005-07-24 Thread ncf
Thank you all for your replies. The repr() solution wasn't exactly what I was looking for, as I wasn't planning on eval()ing it, but the (en|de)code solution was exactly what I was looking for. An extended thanks to Jp for informing me of the version compatibility :) Have a GREAT day :) -Wes --

Re: Simple Problem

2005-07-24 Thread Jp Calderone
On 24 Jul 2005 18:14:13 -0700, ncf <[EMAIL PROTECTED]> wrote: >I know I've seen this somewhere before, but does anyone know what the >function to escape a string is? (i.e., encoding newline to "\n" and a >chr(254) to "\xfe") (and visa-versa) > >Thanks for helping my ignorance :P Python 2.4.1 (

Re: Simple Problem

2005-07-24 Thread Robert Kern
ncf wrote: > I know I've seen this somewhere before, but does anyone know what the > function to escape a string is? (i.e., encoding newline to "\n" and a > chr(254) to "\xfe") (and visa-versa) In [1]: s = "foo\n\xfe" In [2]: s.encode("string_escape") Out[2]: 'foo\\n\\xfe' In [3]: repr(s)[1:-1]

Re: Simple Problem

2005-07-24 Thread Paul Rubin
"ncf" <[EMAIL PROTECTED]> writes: > I know I've seen this somewhere before, but does anyone know what the > function to escape a string is? (i.e., encoding newline to "\n" and a > chr(254) to "\xfe") (and visa-versa) repr(s) -- http://mail.python.org/mailman/listinfo/python-list

Re: Simple Problem

2005-07-24 Thread Cyril Bazin
By any chance are you speaking about the function "repr" ? Cyril On 24 Jul 2005 18:14:13 -0700, ncf <[EMAIL PROTECTED]> wrote: I know I've seen this somewhere before, but does anyone know what thefunction to escape a string is? (i.e., encoding newline to "\n" and achr(254) to "\xfe") (and visa-vers

Simple Problem

2005-07-24 Thread ncf
I know I've seen this somewhere before, but does anyone know what the function to escape a string is? (i.e., encoding newline to "\n" and a chr(254) to "\xfe") (and visa-versa) Thanks for helping my ignorance :P -Wes -- http://mail.python.org/mailman/listinfo/python-list