Re: subprocess in Command promt+ webbrowser

2010-06-18 Thread shanti bhushan
On Jun 19, 11:01 am, shanti bhushan wrote: > I have a code ,in which i invoke the local webserver in back > ground ,then open URL and access the web page. > below is my code. > I am able to invoke and kill the local webserver in seperate python > script,but when i club opening of browser and and s

Re: GUIs - A Modest Proposal

2010-06-18 Thread Matt
On 06/17/2010 08:50 AM, Grant Edwards wrote: On 2010-06-16, Matt wrote: On 06/05/2010 09:22 PM, ant wrote: PyQt is tied to one platform. Several posters have asked for support for or clarification of this claim of yours. Let me guess... The one platform it's tied to is Qt? good answ

Re: GUIs - A Modest Proposal

2010-06-18 Thread est
> > Having said all that, I would like to eliminate some of the > depedencie. At some point I'll probably re-do the Windows > implementation using ctypes, because pywin32/mfc is hindering > more than helping in some areas. I'm also thinking about ways > to interface directly with Cocoa without goin

subprocess in Command promt+ webbrowser

2010-06-18 Thread shanti bhushan
I have a code ,in which i invoke the local webserver in back ground ,then open URL and access the web page. below is my code. I am able to invoke and kill the local webserver in seperate python script,but when i club opening of browser and and subprocess , my like below ,then my script is not respo

500 tracker orphans; we need more reviewers

2010-06-18 Thread Terry Reedy
Go to the bottom of http://bugs.python.org/iss...@template=search&status=1 enter 1 in the Message Count box and hit Search. At the moment, this gets 510 hits. Some have had headers updated, nearly half have had a person add himself as 'nosy' (put 1 in the Nosy count box to count those that have

Re: GUIs - A Modest Proposal

2010-06-18 Thread Kevin Walzer
On 6/18/10 6:16 PM, Jeff Hobbs wrote: Is there a good web-site / tutorial / book / etc that you would recommend for getting a good handle on Tk 8.5? Most of the Tk 8.5 references will be Tcl-based, but one that is cross- language is Mark Roseman's www.tkdocs.com. For books, there is John Ous

Re: Communicating with a program using subprocess

2010-06-18 Thread Nobody
On Thu, 17 Jun 2010 11:22:37 +0200, Laurent Verweijen wrote: > This is easy to understand, but I want to pipe it's input/output > by another python program. (I will show what I am doing on the > console to test it) > > >>> from subprocess import * > >>> p =

Re: How do I fix this test so it runs on Windows? (it uses tzset)

2010-06-18 Thread Nobody
On Thu, 17 Jun 2010 11:45:03 +0100, Chris Withers wrote: >> For whatever reason, tython's "time" module doesn't provide the tzset() >> function on Windows. However, you should be able to use it via ctypes. > > This sounds pretty heavyweight for a unit test. > I'm not even sure how I would do this

Re: max time threads

2010-06-18 Thread MRAB
pacopyc wrote: On 19 Giu, 00:27, MRAB wrote: pacopyc wrote: [snip] Ok, the problem is that I want fix a time max for each thread. For example run 10 threads (each can terminate its work in 10 sec. max fixed time) and wait them. If they finish its work in < 10 sec. (for example 2 sec.) very go

Re: constructing an object from another instance of the same class

2010-06-18 Thread Christoph Groth
Steven D'Aprano writes: > On Fri, 18 Jun 2010 16:30:00 +0200, Christoph Groth wrote: > >> If other is of type Base already, just "pass it on". Otherwise, >> construct an instance of Base from it. >> >> import >> numpy as np >> >>

Re: max time threads

2010-06-18 Thread pacopyc
On 19 Giu, 00:27, MRAB wrote: > pacopyc wrote: > > [snip] > > Ok, the problem is that I want fix a time max for each thread. For > > example run 10 threads (each can terminate its work in 10 sec. max > > fixed time) and wait them. If they finish its work in < 10 sec. (for > > example 2 sec.) very

Re: constructing an object from another instance of the same class

2010-06-18 Thread Christoph Groth
Bruno Desthuilliers writes: > Anyway: the simplest solution here is to replace the call to your Base > class with a call to a factory function. I'd probably go for something > like (Q&D untested code and other usual warnings) : > > (...) Yeah, that will do what I want. My confusion arose from t

Re: max time threads

2010-06-18 Thread MRAB
pacopyc wrote: [snip] Ok, the problem is that I want fix a time max for each thread. For example run 10 threads (each can terminate its work in 10 sec. max fixed time) and wait them. If they finish its work in < 10 sec. (for example 2 sec.) very good ... go on immediately (don't wait unnecessa

Re: GUIs - A Modest Proposal

2010-06-18 Thread Jeff Hobbs
On Jun 18, 2:59 pm, Ethan Furman wrote: > Jeff Hobbs wrote: > > On Jun 6, 2:11 pm, rantingrick wrote: > >> On Jun 6, 2:06 pm, Mark Lawrence wrote: > >>> On 06/06/2010 16:31, rantingrick wrote: > On Jun 5, 9:22 pm, ant  wrote: > > I ask the group; should we try to create a new GUI for Py

Re: I run into a problem in opening a file in Python

2010-06-18 Thread Terry Reedy
On 6/18/2010 4:26 PM, Justin Park wrote: The problem is simple. I have 50taxa2HGT_1.txt in the current directory, and I can open it using any text editor (which indicates there actually is.) And I can read it in Python using fd=open("./50taxa2HGT_1.txt", "r") , and it actually got opened, beca

Re: max time threads

2010-06-18 Thread pacopyc
On 18 Giu, 01:04, MRAB wrote: > pacopyc wrote: > > Hi, I'm trying to work with threads and I need your help. This is > > code: > > > from threading import Thread > > from Queue import Queue > > import time > > import random > > > def test_fun (k,q,t): > >     time.sleep(t) > >     print "hello wor

Re: GUIs - A Modest Proposal

2010-06-18 Thread Ethan Furman
Jeff Hobbs wrote: On Jun 6, 2:11 pm, rantingrick wrote: On Jun 6, 2:06 pm, Mark Lawrence wrote: On 06/06/2010 16:31, rantingrick wrote: On Jun 5, 9:22 pm, ant wrote: I ask the group; should we try to create a new GUI for Python, with the following properties?: - Pythonic - The default GUI

Re: Generator (re-)definition within a loop

2010-06-18 Thread Terry Reedy
On 6/18/2010 3:57 PM, Pierre Reinbold wrote: Hi all, This is my first post on the list. I'm mainly a sysadmin and no expert in programming languages, so this may be a stupid question no but it puzzles me. I was pondering on the documentation of the function product(*args, **kwds) in the ite

Re: I run into a problem in opening a file in Python

2010-06-18 Thread D'Arcy J.M. Cain
On Fri, 18 Jun 2010 17:22:00 -0400 "D'Arcy J.M. Cain" wrote: > By the way, your email address doesn't work. I get a "relay access > denied" message. Ignore that. It was a local problem that I fixed before sending but forgot to remove this paragraph. -- D'Arcy J.M. Cain | Democracy i

Re: I run into a problem in opening a file in Python

2010-06-18 Thread D'Arcy J.M. Cain
On Fri, 18 Jun 2010 15:26:14 -0500 Justin Park wrote: > But when I change the file access mode into "a", > it returns an error message of "IOError: [Errno 9] Bad file descriptor. " Exact test script and traceback please. I would like to see what line gives you the error. Are you trying to read

Re: I run into a problem in opening a file in Python

2010-06-18 Thread MRAB
Justin Park wrote: The problem is simple. I have 50taxa2HGT_1.txt in the current directory, and I can open it using any text editor (which indicates there actually is.) And I can read it in Python using fd=open("./50taxa2HGT_1.txt", "r") , and it actually got opened, because I can do for line

Re: GUIs - A Modest Proposal

2010-06-18 Thread Jeff Hobbs
On Jun 6, 2:11 pm, rantingrick wrote: > On Jun 6, 2:06 pm, Mark Lawrence wrote: > > On 06/06/2010 16:31, rantingrick wrote: > > > > On Jun 5, 9:22 pm, ant  wrote: > > > >> I ask the group; should we try to create a new GUI for Python, with > > >> the following > > >> properties?: > > > >> - Pytho

Re: I run into a problem in opening a file in Python

2010-06-18 Thread Ian Kelly
On Fri, Jun 18, 2010 at 2:26 PM, Justin Park wrote: > But when I change the file access mode into "a", > it returns an error message of "IOError: [Errno 9] Bad file descriptor. " > > What have I done wrong? "a" is for appending only. You can't read from a file opened in that mode. If you want t

Re: GUIs - A Modest Proposal

2010-06-18 Thread Jeff Hobbs
On Jun 10, 1:13 am, "Martin v. Loewis" wrote: > > That said, PerlTk didn't use Tcl did it? > > If you are referring tohttp://search.cpan.org/~srezic/Tk-804.028/- > this also has a full Tcl interpreter, in pTk/mTk, and uses Tcl_Interp > and Tcl_Obj throughout. From the Perl/Tk FAQ (*): > > "However

I run into a problem in opening a file in Python

2010-06-18 Thread Justin Park
The problem is simple. I have 50taxa2HGT_1.txt in the current directory, and I can open it using any text editor (which indicates there actually is.) And I can read it in Python using >>> fd=open("./50taxa2HGT_1.txt", "r") , and it actually got opened, because I can do >>> for line in fd: ...

Re: Help with suds: HTTP Error 401

2010-06-18 Thread plainsane
On Jun 11, 8:27 am, Eric von Horst wrote: > Hi, > > I am trying to do a very simple thing with SUDS but I think I am > missing the obvious (first time I use suds) > > I have small program that tries to open a wsdl. When I execute the > program I am getting 'suds.transport.TransportError: HTTP Erro

Generator (re-)definition within a loop

2010-06-18 Thread Pierre Reinbold
Hi all, This is my first post on the list. I'm mainly a sysadmin and no expert in programming languages, so this may be a stupid question but it puzzles me. I was pondering on the documentation of the function product(*args, **kwds) in the itertools module. It is said that: This function is equi

Re: how to convert a sudsobject into its representative XML?

2010-06-18 Thread Phlip
The answer is to use ZSI instead, then call: sw = SoapWriter() sw.serialize(msg) -- http://mail.python.org/mailman/listinfo/python-list

Re: Jewish Pirates of the Mediteranean

2010-06-18 Thread small Pox
Excellen VIDEO !!! Verrry Rare !!! http://watch.ctv.ca/news/latest/air-india-report/#clip314854 On Jun 17, 8:41 pm, small Pox wrote: > Excellent Video, VERRRY RARE !!! > > http://www.youtube.com/watch?v=r-72jGkGbsg > > On Jun 16, 2:25 am, nanothermite911fbibustards > > wrote: > > Jewish Pi

Re: Possible to reach back in stack and grab calling function's locals()?

2010-06-18 Thread python
Ryan, Thank you very much - your example is exactly the technique I was looking for. My use case is unusual and we don't need to update the parent's version of locals(). The code in question is an internal template library whose methods need access to their caller's locals() so they can figure o

Re: catching my own exception

2010-06-18 Thread Peter Otten
nick wrote: > I have a problem with catching my own exception. Here is the code: > http://fly.srk.fer.hr/~nick/travapi/blame.php?repname=Travian+API&path=%2Fvillage.py&; > > Line 252 calls a method, which on line 207 raises a > SomethingBeingBuiltError exception. On line 253 I catch that > excep

Re: catching my own exception

2010-06-18 Thread nick
Dana Fri, 18 Jun 2010 10:36:21 -0700 (PDT), Jon Clements kaze: > http://www.travian.com/spielregeln.php -- rule 3??? Yeah, I know. If it's any consolation to you, I'm not doing it for the fun of wining the game (hence not bothering to hide de code) but for the fun of coding the API. :-) Anyway,

Re: super() woes (n00b)

2010-06-18 Thread Ethan Furman
Deadly Dirk wrote: On Thu, 17 Jun 2010 12:18:33 -0700, Ethan Furman wrote: Deadly Dirk wrote: On Thu, 17 Jun 2010 13:48:45 -0400, J. Cliff Dyer wrote: super gives you an instantiated version of the super class, which means that you don't have to explicitly send self to any methods you call o

Re: catching my own exception

2010-06-18 Thread Steven D'Aprano
On Fri, 18 Jun 2010 17:08:45 +, nick wrote: > I have a problem with catching my own exception. Here is the code: > http://fly.srk.fer.hr/~nick/travapi/blame.php?repname=Travian+API&path=% 2Fvillage.py& > > Line 252 calls a method, which on line 207 raises a > SomethingBeingBuiltError exception

daemonizing after binding to port

2010-06-18 Thread mk
Hello everyone, I'm starting a SocketServer.TCPServer in my program, but since I want to report problems to script starting the program, I want to go daemon *after* TCPServer has done binding to port. Is this likely to cause problems? I mean, my client works when I do the above, that is, it

Re: catching my own exception

2010-06-18 Thread Jon Clements
On 18 June, 18:08, nick wrote: > I have a problem with catching my own exception. Here is the > code:http://fly.srk.fer.hr/~nick/travapi/blame.php?repname=Travian+API&pat... > > Line 252 calls a method, which on line 207 raises a > SomethingBeingBuiltError exception. On line 253 I catch that > ex

announcing jsonutil package

2010-06-18 Thread Zooko O'Whielacronx
Folks: I've uploaded a small package to PyPI which is a small wrapper around simplejson that sets the default behavior so that JSON decimal values are mapped to type Decimal instead of type float: http://pypi.python.org/pypi/jsonutil It has pretty thorough unit tests, including a copy of all the

Re: creating application specific files?

2010-06-18 Thread Stephen Hansen
On 6/18/10 10:03 AM, muhannad shubita wrote: > hello there, how can i create a new file type and associate it with a > program, for example create a type like .XXX file and give it the > application icon, and when double-clicked on the file the application > runs This has nothing to do with Py

i18n for applications and modules

2010-06-18 Thread Hans-Joachim Widmaier
Internationalizing Python applications is not really hard, and there are some useful how-tos available for the beginner. I've written several (still smallish) applications and localized them. Although it works, it has some rather inelegant areas or rough edges that keep nagging me. 1. Python

Re: creating application specific files?

2010-06-18 Thread MRAB
muhannad shubita wrote: hello there, how can i create a new file type and associate it with a program, for example create a type like .XXX file and give it the application icon, and when double-clicked on the file the application runs [windows platform] help is appreciated. In Wi

catching my own exception

2010-06-18 Thread nick
I have a problem with catching my own exception. Here is the code: http://fly.srk.fer.hr/~nick/travapi/blame.php?repname=Travian+API&path=%2Fvillage.py&; Line 252 calls a method, which on line 207 raises a SomethingBeingBuiltError exception. On line 253 I catch that exception, but when I run that

creating application specific files?

2010-06-18 Thread muhannad shubita
hello there, how can i create a new file type and associate it with a program, for example create a type like .XXX file and give it the application icon, and when double-clicked on the file the application runs [windows platform] help is appreciated. -- http://mail.python.org/mailman/lis

Re: Jewish Pirates of the Caribbean

2010-06-18 Thread Mick
George Neuner DESERVES his FREEDOM OF SPEECH. Freedom of speech dousn't guarantee an audience -- http://mail.python.org/mailman/listinfo/python-list

Re: List of lists surprising behaviour

2010-06-18 Thread Stephen Hansen
On 6/18/10 8:40 AM, bart.c wrote: > I suppose there are pros and cons to both approaches; copying all the time > at least avoids some of the odd effects and inconsistencies you get using > Python: What inconsistencies? All your examples are perfectly consistent. Its just consistent to different id

Re: using subprocess.Popen does not suppress terminal window on Windows

2010-06-18 Thread Alf P. Steinbach
* Steven, on 18.06.2010 18:23: I am calling a ruby program from a python gui and using subprocess.Popen in Windows XP using python 2.6. Unfortunately, whenever the ruby program is called a blank command window appears on screen, annoying my users. Is there a way to suppress this behaviour? Ye

using subprocess.Popen does not suppress terminal window on Windows

2010-06-18 Thread Steven
I am calling a ruby program from a python gui and using subprocess.Popen in Windows XP using python 2.6. Unfortunately, whenever the ruby program is called a blank command window appears on screen, annoying my users. Is there a way to suppress this behaviour? Below is a minimal program that demo

Re: cannot get html content of tag with BeautifulSoup

2010-06-18 Thread someone
On Jun 18, 5:41 pm, someone wrote: > Hello, > > does anyone know how to get html contents of an tag with > BeautifulSoup? In example I'd like to get all html which is in first > tag, i.e. This is paragraph one. as > unicode object > > p.contents gives me a list which I cannot join TypeError: sequ

Re: pythonize this!

2010-06-18 Thread Mark Lawrence
On 18/06/2010 16:26, Andre Alexander Bell wrote: On 06/18/2010 03:32 PM, Mark Lawrence wrote: The good news is that this is easily the fastest piece of code that I've seen yet. The bad news is that first prize in the speed competition is a night out with me. :) Well, that actually means that

Re: The inverse of .join

2010-06-18 Thread Neil Cerutti
On 2010-06-18, Jon Clements wrote: >> I just wondered if something smoother was available. > > In terms of behaviour and 'safety', I'd go for: > rec = { 'code1': '1,2,3', 'code2': '' } next(csv.reader([rec['code1']])) > ['1', '2', '3'] next(csv.reader([rec['code2']])) > [] Slick!

Re: Running a program from another program.

2010-06-18 Thread Laurent Verweijen
Op donderdag 17-06-2010 om 15:16 uur [tijdzone -0700], schreef Stephen Hansen: > On 6/17/10 3:06 PM, Laurent Verweijen wrote: > >> > >> In your other thread you include an actual traceback: > >> > >> Traceback (most recent call last): > >> File "subchronous_test.py", line 5, in > >> send_al

cannot get html content of tag with BeautifulSoup

2010-06-18 Thread someone
Hello, does anyone know how to get html contents of an tag with BeautifulSoup? In example I'd like to get all html which is in first tag, i.e. This is paragraph one. as unicode object p.contents gives me a list which I cannot join TypeError: sequence item 0: expected string, Tag found Thanks!

Re: List of lists surprising behaviour

2010-06-18 Thread bart.c
"Steven D'Aprano" wrote in message news:4c1b8ac6$0$14148$c3e8...@news.astraweb.com... On Fri, 18 Jun 2010 12:07:38 +0100, bart.c wrote: (Although I have an issue with the way that that append works. I tried it in another, simpler language (which always does deep copies): L:=(1,2,3) L append:

Re: The inverse of .join

2010-06-18 Thread Jon Clements
On 17 June, 21:03, Neil Cerutti wrote: > On 2010-06-17, Robert Kern wrote: > > > On 6/17/10 2:08 PM, Neil Cerutti wrote: > >> On 2010-06-17, Ian Kelly  wrote: > >>> On Thu, Jun 17, 2010 at 11:45 AM, Neil Cerutti > >>>  wrote: > What's the best way to do the inverse operation of the .join >

Re: pythonize this!

2010-06-18 Thread Andre Alexander Bell
On 06/18/2010 03:32 PM, Mark Lawrence wrote: > The good news is that this is easily the fastest piece of code that I've > seen yet. The bad news is that first prize in the speed competition is > a night out with me. :) Well, that actually means that Stefan Behnel will run my solution through cyth

Re: constructing an object from another instance of the same class

2010-06-18 Thread Steven D'Aprano
On Fri, 18 Jun 2010 16:30:00 +0200, Christoph Groth wrote: > If other is of type Base already, just "pass it on". Otherwise, > construct an instance of Base from it. > > import > numpy as np > > class Base: > def __init__(self

Re: constructing an object from another instance of the same class

2010-06-18 Thread Stephen Hansen
On 6/18/10 3:51 AM, Christoph Groth wrote: > sometimes it is handy to have a function which can take as argument > anything which can be converted into something, e.g. [snip] > I would like to mimic this behavior of float for a user-defined type, > e.g. [snip] > Now I wonder what is the most pytho

Re: pythonize this!

2010-06-18 Thread Mark Lawrence
On 18/06/2010 16:00, Steven D'Aprano wrote: On Fri, 18 Jun 2010 14:32:30 +0100, Mark Lawrence wrote: The good news is that this is easily the fastest piece of code that I've seen yet. The bad news is that first prize in the speed competition is a night out with me. I suppose second prize is

Re: constructing an object from another instance of the same class

2010-06-18 Thread Bruno Desthuilliers
Bruno Desthuilliers a écrit : Christoph Groth a écrit : Bruno Desthuilliers writes: (snip) In C++ Forget about C++ - Python is a different beast !-) Still, it is useful and interesting to compare languages. Indeed. But you have to understand enough of a language to compare it with ano

Re: constructing an object from another instance of the same class

2010-06-18 Thread Bruno Desthuilliers
Christoph Groth a écrit : Bruno Desthuilliers writes: It seems to me that in this way I might get problems when I pass an instance of Derived_from_my_type to bar, as it will become an instance of My_type. The instance you pass to bar won't "become" anything else. You create a new My_type inst

Re: List of lists surprising behaviour

2010-06-18 Thread Steven D'Aprano
On Fri, 18 Jun 2010 12:07:38 +0100, bart.c wrote: > (Although I have an issue with the way that that append works. I tried > it in another, simpler language (which always does deep copies): > > L:=(1,2,3) > L append:= L > print L > > output: (1,2,3,(1,2,3)) > > which is exactly what I'd expect

Re: pythonize this!

2010-06-18 Thread Steven D'Aprano
On Fri, 18 Jun 2010 14:32:30 +0100, Mark Lawrence wrote: > The good news is that this is easily the fastest piece of code that I've > seen yet. The bad news is that first prize in the speed competition is > a night out with me. I suppose second prize is two nights out with you? -- Steven --

Re: super() woes (n00b)

2010-06-18 Thread Jean-Michel Pichavant
Deadly Dirk wrote: On Fri, 18 Jun 2010 11:19:56 +0200, Jean-Michel Pichavant wrote: Deadly Dirk wrote: I cannot get right the super() function: Python 3.1.1+ (r311:74480, Nov 2 2009, 14:49:22) [GCC 4.4.1] on linux2 Type "copyright", "credits" or "license()" for more information.

Re: constructing an object from another instance of the same class

2010-06-18 Thread Christoph Groth
Bruno Desthuilliers writes: >> It seems to me that in this way I might get problems when I pass an >> instance of Derived_from_my_type to bar, as it will become an >> instance of My_type. > > The instance you pass to bar won't "become" anything else. You create > a new My_type instance from the D

Re: variable variables

2010-06-18 Thread Jean-Michel Pichavant
someone wrote: On Jun 18, 12:49 pm, James Mills wrote: On Fri, Jun 18, 2010 at 8:31 PM, someone wrote: I was looking for a "short way" to do it because I have a lot "some_object.attr.attr or some_object.other_attr.attr" in code. it looks like I cannot replace attr with just other vari

Re: variable variables

2010-06-18 Thread someone
On Jun 18, 2:37 pm, Bruno Desthuilliers wrote: > someone a crit : > > > On Jun 18, 2:05 pm, Bruno Desthuilliers > 42.desthuilli...@websiteburo.invalid> wrote: > (snip) > > >> Still has a "code smell" thing to me, but hard to say not knowing the > >> real code and context. > > > sorry, code is not

Re: pythonize this!

2010-06-18 Thread Mark Lawrence
On 18/06/2010 10:23, Andre Alexander Bell wrote: On 06/16/2010 12:47 PM, Lie Ryan wrote: Probably bending the rules a little bit: sum(x**2 - 8*x - 20 for x in range(1, 2010, 5)) 536926141 Bending them even further, the sum of the squares from 1 to N is given by (1) N*(N+1)*(2*N+1)/6. The

Re: MAKE UPTO $5000 MONTHLY! $2000 INYOUR FIRST 30 DAYS!

2010-06-18 Thread Vannia Rajan
On Fri, Jun 18, 2010 at 4:50 PM, james wrote: > MAKE UP TO $5000 PER MONTH $2000 IN FIRST 30 DAYS > ... > Get paid for your real work and earn awesome > I hope the List administrator has noticed this misuse. -- Thanks, Vanniarajan -- http://mail.python.org/mailman/listinfo/python

Re: super() woes (n00b)

2010-06-18 Thread Deadly Dirk
On Fri, 18 Jun 2010 11:19:56 +0200, Jean-Michel Pichavant wrote: > Deadly Dirk wrote: >> I cannot get right the super() function: Python 3.1.1+ (r311:74480, Nov >> 2 2009, 14:49:22) [GCC 4.4.1] on linux2 >> Type "copyright", "credits" or "license()" for more information. >> No Subprocess ===

Re: super() woes (n00b)

2010-06-18 Thread Deadly Dirk
On Thu, 17 Jun 2010 12:18:33 -0700, Ethan Furman wrote: > Deadly Dirk wrote: >> On Thu, 17 Jun 2010 13:48:45 -0400, J. Cliff Dyer wrote: >> >>> super gives you an instantiated version of the super class, which >>> means that you don't have to explicitly send self to any methods you >>> call on it

Re: The inverse of .join

2010-06-18 Thread Neil Cerutti
On 2010-06-18, Steven D'Aprano wrote: > On Thu, 17 Jun 2010 20:03:42 +, Neil Cerutti wrote: >> I'm currently using the following without problems, while >> reading a data file. One of the fields is a comma separated >> list, and may be empty. >> >> f = rec['codes'] >> if f == "": >> f

Re: variable variables

2010-06-18 Thread Bruno Desthuilliers
someone a écrit : On Jun 18, 2:05 pm, Bruno Desthuilliers wrote: (snip) Still has a "code smell" thing to me, but hard to say not knowing the real code and context. sorry, code is not about printing variables rather accessing, it's just example. Yeps, this I understood - hence the "but..

Re: constructing an object from another instance of the same class

2010-06-18 Thread Bruno Desthuilliers
Christoph Groth a écrit : Dear all, sometimes it is handy to have a function which can take as argument anything which can be converted into something, e.g. def foo(arg): arg = float(arg) # ... I would like to mimic this behavior of float for a user-defined type, e.g. def bar(arg):

Re: variable variables

2010-06-18 Thread someone
On Jun 18, 2:05 pm, Bruno Desthuilliers wrote: > someone a crit : > > > > > > > On Jun 18, 12:49 pm, James Mills wrote: > >> On Fri, Jun 18, 2010 at 8:31 PM, someone wrote: > >>> I was looking for a "short way" to do it because I have a lot > >>> "some_object.attr.attr or some_object.other_attr.

Re: variable variables

2010-06-18 Thread Bruno Desthuilliers
someone a écrit : On Jun 18, 12:49 pm, James Mills wrote: On Fri, Jun 18, 2010 at 8:31 PM, someone wrote: I was looking for a "short way" to do it because I have a lot "some_object.attr.attr or some_object.other_attr.attr" in code. it looks like I cannot replace attr with just other variable

Re: variable variables

2010-06-18 Thread someone
On Jun 18, 12:49 pm, James Mills wrote: > On Fri, Jun 18, 2010 at 8:31 PM, someone wrote: > > I was looking for a "short way" to do it because I have a lot > > "some_object.attr.attr or some_object.other_attr.attr" in code. it > > looks like I cannot replace attr with just other variable and must

MAKE UPTO $5000 MONTHLY! $2000 INYOUR FIRST 30 DAYS!

2010-06-18 Thread james
MAKE UP TO $5000 PER MONTH $2000 IN FIRST 30 DAYS Generate $50 to $100 whenever you have a couple of hours free time tospare. You could make $50 or more in the next 2 hours. Starting right Now! Today! Awesome earnings get paid for your honest work Join as a free member and get paid to your bank ac

Serialization, save type information in file and restore them

2010-06-18 Thread Timothy Wu
Hi, I created a class that's able to manipulate tabulated data. I want to be able to dump the bulk of the data and other attributes as a tab-delimited text. I have trouble saving/restoring type information in the file. For example, some attributes are int, others may be float, etc. So I want to st

Re: List of lists surprising behaviour

2010-06-18 Thread bart.c
Lie Ryan wrote: On 06/18/10 20:00, bart.c wrote: (I don't know if Python allows circular references, but that would give problems anyway: how would you even print out such a list?) Python uses ellipsis to indicate recursive list: a = [1, 2, 3] a.append(a) a [1, 2, 3, [...]] Ok, perhaps w

constructing an object from another instance of the same class

2010-06-18 Thread Christoph Groth
Dear all, sometimes it is handy to have a function which can take as argument anything which can be converted into something, e.g. def foo(arg): arg = float(arg) # ... I would like to mimic this behavior of float for a user-defined type, e.g. def bar(arg): arg = My_type(arg) #

Re: variable variables

2010-06-18 Thread James Mills
On Fri, Jun 18, 2010 at 8:31 PM, someone wrote: > I was looking for a "short way" to do it because I have a lot > "some_object.attr.attr or some_object.other_attr.attr" in code. it > looks like I cannot replace attr with just other variable and must > type some_object.other_attr.attr or your solut

Re: List of lists surprising behaviour

2010-06-18 Thread Lie Ryan
On 06/18/10 20:00, bart.c wrote: > (I > don't know if Python allows circular references, but that would give > problems anyway: how would you even print out such a list?) Python uses ellipsis to indicate recursive list: >>> a = [1, 2, 3] >>> a.append(a) >>> a [1, 2, 3, [...]] -- http://mail.pyt

Re: variable variables

2010-06-18 Thread Lie Ryan
On 06/18/10 20:31, someone wrote: > On Jun 18, 12:01 pm, "Gabriel Genellina" > wrote: >> En Fri, 18 Jun 2010 06:48:34 -0300, someone >> escribió: >> >>> is it possible to make first attr variable? >> >>> some_object.attr.attr >> >>> so instead of attr I could use self.foo which has value "attr"

Re: variable variables

2010-06-18 Thread someone
On Jun 18, 12:01 pm, "Gabriel Genellina" wrote: > En Fri, 18 Jun 2010 06:48:34 -0300, someone   > escribió: > > > is it possible to make first attr variable? > > > some_object.attr.attr > > > so instead of attr I could use self.foo which has value "attr" > > I think you're looking for > getattr:

Re: pythonize this!

2010-06-18 Thread Stefan Behnel
Peter Otten, 18.06.2010 12:14: Stefan Behnel wrote: Andre Alexander Bell, 18.06.2010 11:23: On 06/16/2010 12:47 PM, Lie Ryan wrote: Probably bending the rules a little bit: sum(x**2 - 8*x - 20 for x in range(1, 2010, 5)) 536926141 Bending them even further, the sum of the squares from 1

Re: List of lists surprising behaviour

2010-06-18 Thread bart.c
Benjamin Kaplan wrote: On Thu, Jun 17, 2010 at 4:20 PM, bart.c wrote: I don't know how Python does things, but an object should either specify a special way of duplicating itself, or lend itself to some standard way of doing so. (So for a list, it's just a question of copying the data in the

Re: super() woes (n00b)

2010-06-18 Thread Lie Ryan
On 06/18/10 19:19, Jean-Michel Pichavant wrote: > Deadly Dirk wrote: >> I cannot get right the super() function: >> Python 3.1.1+ (r311:74480, Nov 2 2009, 14:49:22) [GCC 4.4.1] on linux2 >> Type "copyright", "credits" or "license()" for more information. >> No Subprocess >> > class

Re: pythonize this!

2010-06-18 Thread Peter Otten
Stefan Behnel wrote: > Andre Alexander Bell, 18.06.2010 11:23: >> On 06/16/2010 12:47 PM, Lie Ryan wrote: >>> Probably bending the rules a little bit: >>> >> sum(x**2 - 8*x - 20 for x in range(1, 2010, 5)) >>> 536926141 >> >> Bending them even further, the sum of the squares from 1 to N is giv

Re: variable variables

2010-06-18 Thread Gabriel Genellina
En Fri, 18 Jun 2010 06:48:34 -0300, someone escribió: is it possible to make first attr variable? some_object.attr.attr so instead of attr I could use self.foo which has value "attr" I think you're looking for getattr: http://docs.python.org/library/functions.html#getattr name = "spam" g

Re: pythonize this!

2010-06-18 Thread Stefan Behnel
Andre Alexander Bell, 18.06.2010 11:23: On 06/16/2010 12:47 PM, Lie Ryan wrote: Probably bending the rules a little bit: sum(x**2 - 8*x - 20 for x in range(1, 2010, 5)) 536926141 Bending them even further, the sum of the squares from 1 to N is given by (1) N*(N+1)*(2*N+1)/6. The given pro

variable variables

2010-06-18 Thread someone
Hello, is it possible to make first attr variable? some_object.attr.attr so instead of attr I could use self.foo which has value "attr" Thanks! -- http://mail.python.org/mailman/listinfo/python-list

Re: pythonize this!

2010-06-18 Thread Andre Alexander Bell
On 06/16/2010 12:47 PM, Lie Ryan wrote: > Probably bending the rules a little bit: > sum(x**2 - 8*x - 20 for x in range(1, 2010, 5)) > 536926141 Bending them even further, the sum of the squares from 1 to N is given by (1) N*(N+1)*(2*N+1)/6. The given problem can be divided into five sums

Re: super() woes (n00b)

2010-06-18 Thread Jean-Michel Pichavant
Deadly Dirk wrote: I cannot get right the super() function: Python 3.1.1+ (r311:74480, Nov 2 2009, 14:49:22) [GCC 4.4.1] on linux2 Type "copyright", "credits" or "license()" for more information. No Subprocess class P: def __init__(__class__,self): print("I

Re: shelve / pickle error

2010-06-18 Thread Peter Otten
Vineet wrote: > Hi ! > I am using python ver 2.6.5 > Trying to use shelve to save an object on the disc. > = > In the code > # There are 'Person' & 'Manager' classes. > # I created instance objects a,b,c from these classes. > > from person import Person, Manage

Re: Import fails (newbie)

2010-06-18 Thread Peter Otten
mhorlick wrote: > I'm a newbie and I have a small problem. After invoking IDLE --> > > Python 3.1.2 (r312:79149, Mar 21 2010, 00:41:52) [MSC v.1500 32 bit > (Intel)] on win32 > Type "copyright", "credits" or "license()" for more information. import os,glob os.chdir('D:/Python_Programs')