Re: raw audio in windows

2006-09-01 Thread Jay
So, are you saying this would be possible to do with the PlaySound function? Fredrik Lundh wrote: > Ben Sizer wrote: > > > Not really. You'll have to convert it to .wav and then pass it to a > > helper app. > > > >

disgrating a list

2006-09-01 Thread jwaixs
Hello, How can I disgrate (probably not a good word for it) a list? For example: a = [1,2] b = 3 c = [a] + [b] # which makes [[1,2],3] Then how can I change c ([[1,2],3]) into [1,2,3]? I have a simple function for this: def flatten(l): r = [] s = [l]

Re: OO on python real life tutorial?

2006-09-01 Thread filippo
Fredrik Lundh ha scritto: > How many do you need ? ;-) (snip) thanks Fredrik, I know there are plenty of tutorials and manuals. I know what classes, inheritance and polymorphism are. My problem is that I cannot figure out how they can help me in my practical problem (my software). The only things

Re: disgrating a list

2006-09-01 Thread Diez B. Roggisch
jwaixs schrieb: > Hello, > > How can I disgrate (probably not a good word for it) a list? For > example: > > a = [1,2] > b = 3 > c = [a] + [b] # which makes [[1,2],3] Why do you wrap a in a list? Just c = a + [b] will do it. Diez -- http://mail.python.org/mailman/listinfo/python-list

Re: Strange import behavior

2006-09-01 Thread Peter Otten
unexpected wrote: > Hey guys, > > I'm having problems importing a file into my python app. Everytime I > try to define the object specified by this file, i.e, > > test = Test(), > > It raises an ImportError exception: ImportError: cannot import name > Test. > > I've declared it as: > > from t

Re: OO on python real life tutorial?

2006-09-01 Thread Diez B. Roggisch
filippo schrieb: > thanks Fredrik and Claudio, > > probably structured coding paradigm is what I need. Claudio, could you > explain better your sentence below? > > Claudio Grondi ha scritto: >> Python/Tk for it in order to avoid programming in wxPython if not really >> necessary (wxPython has its

Re: disgrating a list

2006-09-01 Thread jwaixs
Diez B. Roggisch wrote: > Why do you wrap a in a list? Just > > c = a + [b] > > will do it. Yes I know, but the problem is I don't know if 'a' is a list or not. I could make a type check, but I don't want to program in that way. Noud -- http://mail.python.org/mailman/listinfo/python-list

Re: a question about ftplib

2006-09-01 Thread Gabriel G
At Friday 1/9/2006 06:32, alper soyler wrote: Thank you very much for your help. The program works however, after downloading 121 '.pep' files, it gave me time out error: Traceback (most recent call last): File "ftp1.0.py", line 18, in ? for filename in ftp.nlst(): ... File "/usr/lib

Incremental Progress Report object/closure?

2006-09-01 Thread Terrence Brannon
'lo all, I'm looking for something that gives feedback to the screen every X iterations, reporting Time elapsed: 0:00:00 X,XXX,XXX records done. speed /second. [Action Label] Such a thingy is useful when one is cranking away at million record flat files and one wants to provide feedback t

Re: disgrating a list

2006-09-01 Thread George Sakkis
jwaixs wrote: > Hello, > > How can I disgrate (probably not a good word for it) a list? For > example: > > a = [1,2] > b = 3 > c = [a] + [b] # which makes [[1,2],3] > > Then how can I change c ([[1,2],3]) into [1,2,3]? I have a simple > function for this: > > def flatt

Re: disgrating a list

2006-09-01 Thread Tim Chase
jwaixs wrote: > Hello, > > How can I disgrate (probably not a good word for it) a list? For > example: > > a = [1,2] > b = 3 > c = [a] + [b] # which makes [[1,2],3] > > Then how can I change c ([[1,2],3]) into [1,2,3]? I have a simple > function for this: > > def fla

Re: disgrating a list

2006-09-01 Thread Peter Otten
jwaixs wrote: > > Diez B. Roggisch wrote: >> Why do you wrap a in a list? Just >> >> c = a + [b] >> >> will do it. > > Yes I know, but the problem is I don't know if 'a' is a list or not. I > could make a type check, but I don't want to program in that way. Somewhere in the call chain you have

Re: Python style: to check or not to check args and data members

2006-09-01 Thread Paddy
Joel Hedlund wrote: > > Hmmm... So. I should build grimly paranoid parsers for external data, use > duck-typed interfaces everywhere on the inside, and simply callously > disregard developers who are disinclined to read documentation? I could do > that. > > > if you're really serious, unit tests

Re: disgrating a list

2006-09-01 Thread Hardcoded Software
Tim Chase wrote: > >>> def flatten(x): > ... q = [] > ... for v in x: > ... if hasattr(v, '__iter__'): > ... q.extend(flatten(v)) > ... else: > ... q.append(v) > ... return q > ... Let's do some nitpicking on "pythonic" s

Re: Incremental Progress Report object/closure?

2006-09-01 Thread George Sakkis
Terrence Brannon wrote: > 'lo all, I'm looking for something that gives feedback to the screen > every X iterations, reporting > > Time elapsed: 0:00:00 X,XXX,XXX records done. speed /second. > [Action Label] > > > Such a thingy is useful when one is cranking away at million record > flat f

Re: disgrating a list

2006-09-01 Thread Tal Einat
Tim Chase wrote: > I'm not sure if '__iter__' is the right thing to be looking for, > but it seems to work at least for lists, sets, dictionarys (via > their keys), etc. I would use it because at least then you know > you can iterate over it AFAIK and as seen throughout posts on c.l.py, the best

RE: Newbie question involving buffered input

2006-09-01 Thread Caolan
Title: Re: Newbie question involving buffered input That makes sense I suppose - why is there a stdin.flush() method then? From: [EMAIL PROTECTED] on behalf of Jean-Paul CalderoneSent: Fri 9/1/2006 9:53 AMTo: python-list@python.orgSubject: Re: Newbie question involving buffered input

Re: python loops

2006-09-01 Thread Paddy
Putty wrote: > In C and C++ and Java, the 'for' statement is a shortcut to make very > concise loops. In python, 'for' iterates over elements in a sequence. > Is there a way to do this in python that's more concise than 'while'? > > C: > for(i=0; i > > python: > while i < length: >

$HOSTNAME not in os.environ?

2006-09-01 Thread slinkp
Can anybody explain this one? [EMAIL PROTECTED] ~ $ python Python 2.4.3 (#1, Jul 27 2006, 13:07:44) [GCC 3.4.6 (Gentoo 3.4.6-r1, ssp-3.4.5-1.0, pie-8.7.9)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> os.environ['HOSTNAME'] Traceback (most rece

Re: disgrating a list

2006-09-01 Thread Neil Cerutti
On 2006-09-01, jwaixs <[EMAIL PROTECTED]> wrote: > Hello, > > How can I disgrate (probably not a good word for it) a list? For > example: > > a = [1,2] > b = 3 > c = [a] + [b] # which makes [[1,2],3] > > Then how can I change c ([[1,2],3]) into [1,2,3]? I have a > simple function for this: You

Re: Python style: to check or not to check args and data members

2006-09-01 Thread Joel Hedlund
> You might try doctests, they can be easier to write and fit into the > unit test framework if needed. While I firmly believe in keeping docs up to date, I don't think that doctests alone can solve the problem of maintaining data integrity in projects with more comlex interfaces (which is what

Re: $HOSTNAME not in os.environ?

2006-09-01 Thread Grant Edwards
On 2006-09-01, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Can anybody explain this one? print os.getenv('HOSTNAME') > None > [EMAIL PROTECTED] ~ $ echo $HOSTNAME > kermit Perhaps the HOSTNAME variable isn't exported? -- Grant Edwards grante Yow! All

Re: os.name under Win32

2006-09-01 Thread Igor Kravtchenko
Hi Fredrik, yes I've checked and I'm sure we don't assign os.name somewhere ourself. I'll replace os.name == "posix" with sys.platform == "win32" as you suggested and see how thing goes. Thanks for your help, Igor. Fredrik Lundh wrote: >Igor Kravtchenko wrote: > > > >>We have an applicatio

Re: Syntax suggestion.

2006-09-01 Thread samir
Bonan tagon! George Sakkis wrote: > It's been done; it's called "IPython": > http://ipython.scipy.org/doc/manual/manual.html Thank you for the link! It's just what I've needed but... Roberto Bonvallet wrote : > ...so finally you get something that is exactly like any Unix shell, and > complete

Re: Incremental Progress Report object/closure?

2006-09-01 Thread Gabriel Genellina
At Friday 1/9/2006 15:07, Terrence Brannon wrote: 'lo all, I'm looking for something that gives feedback to the screen every X iterations, reporting Time elapsed: 0:00:00 X,XXX,XXX records done. speed /second. [Action Label] What about a simple: print "Time elapsed: blah blah blah\r"

Re: Threads and Progress Bar

2006-09-01 Thread Ritesh Raj Sarraf
Dennis Lee Bieber on Friday 01 Sep 2006 23:04 wrote: > Well... first off -- some minimal code would be of use... > I was scared that people might feel that I'm asking for a ready-made solution. :-) Here's the code. The is the progress bar code. progressbar.py class progressBar: def __init__

Re: disgrating a list

2006-09-01 Thread Neil Cerutti
On 2006-09-01, Tal Einat <[EMAIL PROTECTED]> wrote: > Tim Chase wrote: >> I'm not sure if '__iter__' is the right thing to be looking >> for, but it seems to work at least for lists, sets, >> dictionarys (via their keys), etc. I would use it because at >> least then you know you can iterate over i

Re: $HOSTNAME not in os.environ?

2006-09-01 Thread slinkp
Grant Edwards wrote: > On 2006-09-01, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Can anybody explain this one? > > print os.getenv('HOSTNAME') > > None > > > [EMAIL PROTECTED] ~ $ echo $HOSTNAME > > kermit > > Perhaps the HOSTNAME variable isn't exported? Aha. Right you are. Thank

Re: Syntax suggestion.

2006-09-01 Thread Simon Forman
samir wrote: > Bonan tagon! > > George Sakkis wrote: > > > It's been done; it's called "IPython": > > http://ipython.scipy.org/doc/manual/manual.html > > Thank you for the link! It's just what I've needed but... > > Roberto Bonvallet wrote : > > > ...so finally you get something that is exactly lik

Re: Syntax suggestion.

2006-09-01 Thread Eirikur Hallgrimsson
>> "if" statement. So i thought that ommiting the parentheses and, why >> not, the commas in such cases will be a sort of beautiful/easier :) >> >> Adiaux >> Samir >> This actually exists. The language which omits punctuation not actually required to resolve ambiguity is called Ruby. Ruby is

Re: OO on python real life tutorial?

2006-09-01 Thread filippo
Diez B. Roggisch ha scritto: > I've been doing an online hotel reservation system, btw, and I assure > you: OO was very helpful, even in its crappy PHP incarnation. thanks Diez, I'll keep trying OO paradigm. Probably the advantages will be clearer to me porting to python my app. Best regards, Fi

Re: where or filter on list

2006-09-01 Thread Larry Bates
What I mean is: What if there are two items that are equidistant to what you are searching for? Example: foo = [-5,-1,1,3,5] print closest(0, foo) -1 and 1 are both "equally close" to zero that I'm searching for. This is an edge case that you didn't define an answer to and closest function tha

Re: Python for Windows

2006-09-01 Thread Larry Bates
mistral wrote: > Larry Bates писал(а): > >> mistral wrote: >>> hg писал(а): > Grant Edwards wrote: > >> Will the msi installer modify registry or other system files? >> Does it possible install Python not touching registry and >> system files? You can make your own installe

pictures as characters in a Tk text box?

2006-09-01 Thread Jay
This may be really obscure, but I had a dream about programming something like this, so don't blame me. Is it possible to take a small image or icon and display it as a character in a Tk text box? Think how Thunderbird displays text smilies as actual smiley icons. Or how in AIM as you type a smi

Re: disgrating a list

2006-09-01 Thread jwaixs
Thank you for all your reply and support. Neil's fits the most to me. I shrinked it to this function: def flatten(x): for i in range(len(x)): if isinstance(x[i], list): x[i:i+1] = x[i] Thank you all again. If someone could find even a cuter way, I'd like to see that way.

Re: Python style: to check or not to check args and data members

2006-09-01 Thread Paddy
Joel Hedlund wrote: > > You might try doctests, they can be easier to write and fit into the > > unit test framework if needed. > > While I firmly believe in keeping docs up to date, I don't think that > doctests alone can solve the problem of maintaining data integrity in > projects with more com

tp_members and T_ULONGLONG ("C" Python modules)

2006-09-01 Thread Gimble
While writing custom modules, I've found the tp_members type entry very useful. (As background, it is a pointer to a constant structure that defines direct access sizes and types of member variables within your custom PyObject ). However, the defined type enumeration (including T_USHORT, T_UINT,

Re: disgrating a list

2006-09-01 Thread Diez B. Roggisch
jwaixs schrieb: > Diez B. Roggisch wrote: >> Why do you wrap a in a list? Just >> >> c = a + [b] >> >> will do it. > > Yes I know, but the problem is I don't know if 'a' is a list or not. I > could make a type check, but I don't want to program in that way. So you're telling us that if not isins

Re: OO on python real life tutorial?

2006-09-01 Thread Claudio Grondi
filippo wrote: > thanks Fredrik and Claudio, > > probably structured coding paradigm is what I need. Claudio, could you > explain better your sentence below? > > Claudio Grondi ha scritto: > >>Python/Tk for it in order to avoid programming in wxPython if not really >>necessary (wxPython has its

Re: ANN: GMPY binaries for Windows 2.5

2006-09-01 Thread [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote: > GMPY binaries for Python 2.5 are available at > http://home.comcast.net/~casevh/ > > Notes > > They have not been extensively tested. They don't work. At least the Pentium4 binary doesn't work, same problem as before. Is the patch installed? Python 2.5c1 (r25c1:51

Re: Python style: to check or not to check args and data members

2006-09-01 Thread Joel Hedlund
> Oh, I was just addressing your bit about not knowing unit tests. > Doctests can be quicker to put together and have only a small learning > curve. OK, I see what you mean. And you're right. I'm struggling mightily right now with trying to come up with sane unit tests for a bunch of generalized

Re: disgrating a list

2006-09-01 Thread Gimble
> def flatten(x): > for i in range(len(x)): > if isinstance(x[i], list): > x[i:i+1] = x[i] I don't think this does what you want. Try [[[1,2,3]]] as a trivial example. A recursive version, that's not as short as yours: def flatten(x): "Recursive example to flatten a

Re: disgrating a list

2006-09-01 Thread George Sakkis
jwaixs wrote: > Thank you for all your reply and support. Neil's fits the most to me. I > shrinked it to this function: > > def flatten(x): > for i in range(len(x)): > if isinstance(x[i], list): > x[i:i+1] = x[i] > > Thank you all again. If someone could find even a cuter w

Re: disgrating a list

2006-09-01 Thread Gimble
Or, (to add needed recursion to your simple loop): def flatten(x): "Modified in-place flattening" for i in range(len(x)): if isinstance(x[i], list): x[i:i+1] = flatten(x[i]) return x This version modifies in-place (as yours does), which may or may not be what you w

C code in Python

2006-09-01 Thread Tommy Grav
I have some numerical code in C that I would like to call from Python. Cananyone point me in a direction for some text I could read on how to do this?Cheers Tommy[EMAIL PROTECTED]http://homepage.mac.com/tgrav/"Any intelligent fool can make things bigger, more complex, and more violent. It takes a t

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

Weekly Python Patch/Bug Summary

2006-09-01 Thread Kurt B. Kaiser
Patch / Bug Summary ___ Patches : 412 open ( +5) / 3397 closed ( +4) / 3809 total ( +9) Bugs: 900 open (+12) / 6149 closed ( +4) / 7049 total (+16) RFE : 233 open ( +1) / 236 closed ( +0) / 469 total ( +1) New / Reopened Patches __ set liter

Re: pictures as characters in a Tk text box?

2006-09-01 Thread Simon Forman
Jay wrote: > This may be really obscure, but I had a dream about programming > something like this, so don't blame me. Is it possible to take a small > image or icon and display it as a character in a Tk text box? Think > how Thunderbird displays text smilies as actual smiley icons. Or how > in

simpleparse parsing problem

2006-09-01 Thread David Hirschfield
Anyone out there use simpleparse? If so, I have a problem that I can't seem to solve...I need to be able to parse this line: """Cen2 = Cen(OUT, "Cep", "ies", wh, 544, (wh/ht));""" with this grammar: grammar = r''' declaration := ws, line, (ws, line)*, ws line:= (statement / assignment),

Re: Using eval with substitutions

2006-09-01 Thread abhishek
Thanks very much for all your suggestions - Peter, Duncan and Frederic. It was a great help. Incidentally the question arose while I was trying to solve the 2-nots problem, http://www.inwap.com/pdp10/hbaker/hakmem/boolean.html#item19 Part of my program takes a set of boolean expressions in 3 vari

Re: disgrating a list

2006-09-01 Thread Simon Forman
jwaixs wrote: > Thank you for all your reply and support. Neil's fits the most to me. I > shrinked it to this function: > > def flatten(x): > for i in range(len(x)): > if isinstance(x[i], list): > x[i:i+1] = x[i] > > Thank you all again. If someone could find even a cuter wa

Re: Timeline for Python?

2006-09-01 Thread Sebastian Bassi
On 1 Sep 2006 00:57:04 -0700, crystalattice <[EMAIL PROTECTED]> wrote: > I'd write for 2.4, even though 2.5 should be coming out "shortly". > There aren't many significant changes to the whole language between 2.4 > and 2.5. Probably the best thing is write for 2.4 and have a sidenote > stating wh

Re: C code in Python

2006-09-01 Thread Robert Kern
Tommy Grav wrote: > I have some numerical code in C that I would like to call from Python. Can > anyone point me in a direction for some text I could read on how to do this? It somewhat depends on the kind of numerical code and the interface it exposes. Do you need to pass arrays back and forth?

IndentationError: expected an indented block

2006-09-01 Thread casioculture
Haha. How can I fix this! -- http://mail.python.org/mailman/listinfo/python-list

Re: simpleparse parsing problem

2006-09-01 Thread Paul McGuire
"David Hirschfield" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Anyone out there use simpleparse? If so, I have a problem that I can't > seem to solve...I need to be able to parse this line: > > """Cen2 = Cen(OUT, "Cep", "ies", wh, 544, (wh/ht));""" > > with this grammar: > > gr

Re: Using eval with substitutions

2006-09-01 Thread Carl Banks
[EMAIL PROTECTED] wrote: > >>> a,b=3,4 > >>> x="a+b" > >>> eval(x) > 7 > >>> y="x+a" > > Now I want to evaluate y by substituting for the evaluated value of x. > eval(y) will try to add "a+b" to 3 and return an error. I could do > this, > >>> eval(y.replace("x",str(eval(x > 10 > > but this beco

Re: IndentationError: expected an indented block

2006-09-01 Thread John Machin
[EMAIL PROTECTED] wrote: > Haha. How can I fix this! Haha to you too. Position your cursor at the scene of the crime. Hit the space-bar 4 times. Hit Ctrl-s. Try running it again. If you would prefer a more sensible answer, you might like to ask a more sensible question, which would include a cop

Re: ANN: GMPY binaries for Windows 2.5

2006-09-01 Thread casevh
> > Notes > > > > They have not been extensively tested. > > They don't work. At least the Pentium4 binary doesn't work, > same problem as before. Is the patch installed? I found the problem. Updated binaries should be available in a couple of hours. I'll add a note to the web page. I tested

Libraries in python

2006-09-01 Thread eduardo . rosa
Hy people, I'm new in python and comming from JAVA. Something I really like in java is the easy way to add a library to the project. Just put the jar file in the folder ( WEB-INF/lib ) and doesn't need to restart the server ( tomcat ). Can I do some like using python - I'm using apache mod_python

Re: Incremental Progress Report object/closure?

2006-09-01 Thread Fredrik Lundh
Gabriel Genellina wrote: > What about a simple: > > print "Time elapsed: blah blah blah\r" % whatever, > > (notice the \r and the final , ) to avoid messing up the output when you're leaving the loop, or if something goes wrong inside the loop, it's usually better to *start* with a carriage r

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: Timeline for Python?

2006-09-01 Thread Fredrik Lundh
Sebastian Bassi wrote: > Maybe I forgot to tell, but its going to take me at least 6 month to > finish the book I don't think anyone will know exactly how 3.0 will look within 6 months. Not that your publisher may care about that; there are plenty of books out there that describe how the autho

<    1   2