Re: Resolve circular reference

2011-01-10 Thread Stefan Behnel

moerchendiser2k3, 10.01.2011 22:19:

On Jan 10, 7:18 pm, Stefan Behnel wrote:

moerchendiser2k3, 10.01.2011 18:55:


If you can tell us why it's so important that the object be destroyed
at that given time, even while a reference to it exists, maybe we can
give you better suggestions.



Thanks for your answer! In my case the types A and B (in my example
above)
are a dialog and a dialog widget. At a special time I have to close
and
destroy all dialogs but this does not happen because the widget keeps
the dialog alive. I have the reference to the dialog
but after I closed the dialogs I also would like to destroy them
because they have to free some special ressources.


Objects within a reference cycle will eventually get cleaned up, just not
right away and not in a predictable order.

If you need immediate cleanup, you should destroy the reference cycle
yourself, e.g. by removing the widgets from the dialog when closing it.

Stefan


The PyWidget type does not own the widget, it just points to it. I
have an idea, would this fix the problem?

I destroy the internal dictionary of the dialog which points to other
PyObjects? Then I would cut the dependency.


Sure, that should work.

Stefan

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


Re: Ideas for a module to process command line arguments

2011-01-10 Thread Alice Bevan–McGregor

On 2011-01-10 21:18:41 -0800, Sohail said:

Hey, every body has their own favorite method/ways to process command 
line arguments. I've worked on a little CPython extension to handle 
command line arguments may be you'll find it interesting and useful


Even I've implemented my own way to handle command-line scripts, marrow.script:

https://github.com/pulp/marrow.script

The idea with mine that you write a Python function... and that's it.  
The latest version has experimental support for class-based 
"subcommand" dispatch, but it needs work, needs to be updated to 
support sub-sub commands, and the help text generator needs to be 
overhauled to support classes properly.


The argument list, typecasting, etc. is built from the argspec.  Help 
text is pulled from the docstring.  Decorators are provided to override 
short names, define explicit callbacks or typecasting functions, etc.


I got tired of using PasteScript and OptParse.  Mostly OptParse, actually.  :/

- Alice.


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


Re: importing modules dynamicly

2011-01-10 Thread Steven D'Aprano
On Mon, 10 Jan 2011 20:42:17 -0800, dubux wrote:

> After loading all the modules, i try to do something like:
> 
> instance = modules.modulename.class()

No you don't. class is a reserved word in Python, you would get a 
SyntaxError if you did that.

Please post the error you get, including the complete traceback, showing 
the line of code that fails. Copy and paste the *actual* message in full, 
don't retype it from memory, paraphrase it, simplify it, translate it 
into Swahili, or otherwise change it in anyway.



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


Re: String to char and decimal number conversion

2011-01-10 Thread SANKAR .
Thanks Alan!

-Sankar

On Tue, Jan 11, 2011 at 2:50 PM, Alan Meyer  wrote:

> On 1/10/2011 6:02 PM, Chris Rebert wrote:
>
>> On Mon, Jan 10, 2011 at 2:44 PM, SANKAR .  wrote:
>>
>>> Hello There,
>>>
>>>
>>>I am from non IT field also new to python programming.Could you
>>> please help me to solve the following problem?
>>>
>>> I have a list T1 with following format:
>>>
>>> T1 = [ ' "Field" ' , ' "12.5" ', ' "2.5" ']
>>>
>>> How do get the list elements without double quote in my output (T2).
>>>
>>> T2 =[ ' Field ' , ' 12.5 ', ' 2.5 ']
>>>
>>
> This will do it:
> 
>
> T1 = [ ' "Field" ' , ' "12.5" ', ' "2.5" ']
> T2 = []
> for t in T1:
>T2.append(t.replace('"', ''))
> 
>
> The "replace" function acts on each element in T1, replacing every double
> quote with nothing.  We then append that to the new list T2.
>
>Alan
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-- 
http://mail.python.org/mailman/listinfo/python-list


You can get careers in Management work.

2011-01-10 Thread gaurav
Great careers in Management work. Management careers bases.
http://topcareer.webs.com/executivemanager.htm
http://rojgars1.webs.com/gov.htm

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


importing modules dynamicly

2011-01-10 Thread dubux
I am trying to import modules dynamicly from a directory (modules/) in
which i have __init__.py with the __all__ variable set. Everything
imports correctly and I have verified this however I am stuck on
actually using my classes in the dynamicly imported modules.

this bit is in my main.py (or base script) to import the modules in
the modules/ directory:

loaded_modules = []
for item in modules:
  if item == '__init__.py': pass
  else:
if item.endswith('.py'):
  __import__('modules.' + item[0:len(item) - 3])
  loaded_modules.append(item[0:len(item) - 3])
else: pass

After loading all the modules, i try to do something like:

instance = modules.modulename.class()

And I get an AttributeError. What am I doing wrong here? Help please!!

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


Re: String to char and decimal number conversion

2011-01-10 Thread Alan Meyer

On 1/10/2011 6:02 PM, Chris Rebert wrote:

On Mon, Jan 10, 2011 at 2:44 PM, SANKAR .  wrote:

Hello There,

I am from non IT field also new to python programming.Could you
please help me to solve the following problem?

I have a list T1 with following format:

T1 = [ ' "Field" ' , ' "12.5" ', ' "2.5" ']

How do get the list elements without double quote in my output (T2).

T2 =[ ' Field ' , ' 12.5 ', ' 2.5 ']


This will do it:

T1 = [ ' "Field" ' , ' "12.5" ', ' "2.5" ']
T2 = []
for t in T1:
T2.append(t.replace('"', ''))


The "replace" function acts on each element in T1, replacing every 
double quote with nothing.  We then append that to the new list T2.


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


Re: Python use growing fast

2011-01-10 Thread Roy Smith
In article ,
 Dan Stromberg  wrote:

> About JavaScript's popularity:
> 1) I've been getting the impression that JavaScript is popular in a
> manner similar to how x86 machine language is popular: That is, it's
> used all over, but few people hand code it (though admittedly, there
> are probably more people hand coding JavaScript than people hand
> coding x86 assembler today)

One of the surprising (to me, anyway) uses of JavaScript is as the 
scripting language for MongoDB (http://www.mongodb.org/).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: apscheduler error

2011-01-10 Thread Alice Bevan–McGregor

On 2011-01-10 17:23:34 -0800, linna li said:


I see the latest version is APScheduler 1.3.1. Where can I get APScheduler 2.0?


https://bitbucket.org/agronholm/apscheduler/

I don't think 2.0 has been released yet, but that is the version number 
in apscheduler/__init__.py on HG tip.  The examples, BTW, just add 
time.sleep() calls.  ;)


- Alice.


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


Re: Python use growing fast

2011-01-10 Thread Corey Richardson
On 01/10/2011 10:24 PM, Dan Stromberg wrote:
> On Mon, Jan 10, 2011 at 5:22 PM, Krzysztof Bieniasz
>  wrote:
>>> Also depends on how one defines "popularity" in the context of
>>> programming languages.
>>
>> Tiobe quite clearly states what they mean by the name "popularity".
>> Namely the number of Google search results of expressions like
>> "programming X" for X in languages. If no one in the Web writes about
>> programming JavaScript then obviously it's not popular... sort of.
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>>
> 
> About JavaScript's popularity:
> 1) I've been getting the impression that JavaScript is popular in a
> manner similar to how x86 machine language is popular: That is, it's
> used all over, but few people hand code it (though admittedly, there
> are probably more people hand coding JavaScript than people hand
> coding x86 assembler today)
> 2) JavaScript seems widely considered a bit of a mess, and yet, many
> tools make use of it because it's in almost all web browsers
> 3) It seems that when JavaScript does get used directly, it tends to
> be done in small snippets, like inline assembler in C or C++
> 4) It appears that there is quite a few different tools (one of them,
> our own Pyjamas, and to a lesser extent, Django - and of course GWT
> though that's only tenuously related to Python through Pyjamas) that
> attempt to take the pain out of writing JavaScript
> 
> IOW, I'm not convinced that Tiobe's ranking of JavaScript is
> inaccurate, or even weakly correlated with reality.

The biggest use of JavaScript I've seen is browser-based games using
them for some display magic, windows popping up etc. Their back-end is
still VB.NET (or x framework), and none of the lifting is done by
JavaScript.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python use growing fast

2011-01-10 Thread Dan Stromberg
On Mon, Jan 10, 2011 at 5:22 PM, Krzysztof Bieniasz
 wrote:
>> Also depends on how one defines "popularity" in the context of
>> programming languages.
>
> Tiobe quite clearly states what they mean by the name "popularity".
> Namely the number of Google search results of expressions like
> "programming X" for X in languages. If no one in the Web writes about
> programming JavaScript then obviously it's not popular... sort of.
> --
> http://mail.python.org/mailman/listinfo/python-list
>

About JavaScript's popularity:
1) I've been getting the impression that JavaScript is popular in a
manner similar to how x86 machine language is popular: That is, it's
used all over, but few people hand code it (though admittedly, there
are probably more people hand coding JavaScript than people hand
coding x86 assembler today)
2) JavaScript seems widely considered a bit of a mess, and yet, many
tools make use of it because it's in almost all web browsers
3) It seems that when JavaScript does get used directly, it tends to
be done in small snippets, like inline assembler in C or C++
4) It appears that there is quite a few different tools (one of them,
our own Pyjamas, and to a lesser extent, Django - and of course GWT
though that's only tenuously related to Python through Pyjamas) that
attempt to take the pain out of writing JavaScript

IOW, I'm not convinced that Tiobe's ranking of JavaScript is
inaccurate, or even weakly correlated with reality.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python use growing fast

2011-01-10 Thread Gerry Reno
On 01/10/2011 08:31 PM, Katie T wrote:
> On Mon, Jan 10, 2011 at 10:29 PM, John Nagle  wrote:
>   
>> On 1/10/2011 1:02 PM, MRAB wrote:
>> 
>>> On 10/01/2011 20:29, Dan Stromberg wrote:
>>>   
 I invite folks to check out Tiobe's Language Popularity Rankings:

 http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
 
>>   That's somehow derived from web searches, not from any real data
>> source.  Look how far down JavaScript is.
>> 
> Any measure is arbitrary and subject to biases, what methodology would
> you prefer ?
>
>
> Katie
>   

Measuring the "Buzz" about a language is actually a pretty good way to
gauge its popularity.

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


Re: apscheduler error

2011-01-10 Thread linna li
On Jan 7, 11:03 pm, Alice Bevan–McGregor  wrote:
> Howdy!
>
> On 2011-01-07 17:08:28 -0800, linna li said:
>
> > I tried to use the apscheduler and used the sample code below from the
> > tutorial, but got the error message: Exception in thread APScheduler
> > (most likely raised during interpreter shutdown). What's going on here?
> > I really appreciate any help!
>
> After talking a bit with Alex Grönholm it seems this is an issue raised
> fairly often (not always in the context of this package) and is not
> really a problem with APScheduler.  It has far more to do with
> attempting to start a thread, then immediately exiting the main thread.
>  That's not how threading is supposed to be used, so don't do it.  ;)
>
> APScheduler 2.0 adds some improved examples, according to Alex, that
> don't suffer the "problem" demonstrated by the short code snippit you
> provided.
>
> A package of mine, TurboMail, suffers from the same threading issue if
> used improperly; you enqueue e-mail, it starts a thread, then you
> immediately exit.  TM tries to work around the issue, but in most cases
> that workaround does not work properly.  (You get strange uncatchable
> exceptions printed on stderr though AFIK the e-mail does get sent
> correctly, your application may hang waiting for the thread pool to
> drain if you have a "minimum thread count" option set.)
>
> I hope this clears things up a bit,
>
>         - Alice.

I see the latest version is APScheduler 1.3.1. Where can I get
APScheduler 2.0?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python use growing fast

2011-01-10 Thread Katie T
On Mon, Jan 10, 2011 at 10:29 PM, John Nagle  wrote:
> On 1/10/2011 1:02 PM, MRAB wrote:
>>
>> On 10/01/2011 20:29, Dan Stromberg wrote:
>>>
>>> I invite folks to check out Tiobe's Language Popularity Rankings:
>>>
>>> http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
>
>   That's somehow derived from web searches, not from any real data
> source.  Look how far down JavaScript is.

Any measure is arbitrary and subject to biases, what methodology would
you prefer ?


Katie
-- 
CoderStack
http://www.coderstack.co.uk/python-jobs
The Software Developer Job Board
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python use growing fast

2011-01-10 Thread Krzysztof Bieniasz
> Also depends on how one defines "popularity" in the context of
> programming languages.

Tiobe quite clearly states what they mean by the name "popularity". 
Namely the number of Google search results of expressions like 
"programming X" for X in languages. If no one in the Web writes about 
programming JavaScript then obviously it's not popular... sort of.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: apscheduler error

2011-01-10 Thread linna li
Thank you for all the replies here! I will try your suggestions.

On Jan 7, 11:03 pm, Alice Bevan–McGregor  wrote:
> Howdy!
>
> On 2011-01-07 17:08:28 -0800, linna li said:
>
> > I tried to use the apscheduler and used the sample code below from the
> > tutorial, but got the error message: Exception in thread APScheduler
> > (most likely raised during interpreter shutdown). What's going on here?
> > I really appreciate any help!
>
> After talking a bit with Alex Grönholm it seems this is an issue raised
> fairly often (not always in the context of this package) and is not
> really a problem with APScheduler.  It has far more to do with
> attempting to start a thread, then immediately exiting the main thread.
>  That's not how threading is supposed to be used, so don't do it.  ;)
>
> APScheduler 2.0 adds some improved examples, according to Alex, that


> don't suffer the "problem" demonstrated by the short code snippit you
> provided.
>
> A package of mine, TurboMail, suffers from the same threading issue if
> used improperly; you enqueue e-mail, it starts a thread, then you
> immediately exit.  TM tries to work around the issue, but in most cases
> that workaround does not work properly.  (You get strange uncatchable
> exceptions printed on stderr though AFIK the e-mail does get sent
> correctly, your application may hang waiting for the thread pool to
> drain if you have a "minimum thread count" option set.)
>
> I hope this clears things up a bit,
>
>         - Alice.

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


Re: Python use growing fast

2011-01-10 Thread Terry Reedy

On 1/10/2011 4:43 PM, Alice Bevan–McGregor wrote:



It shows an example of Python code, which happens to have 2 syntax
errors!


Wikipedia is a Wiki; everyone is free to contribute and correct mistakes.


The errors, if there, are in .png and .svg images of a random, 
unrunnable snippet that will disappear in a week (at least the .png) due 
to lack of copyright release.


A complete example that runs, pulled from the tutorial, would be good. I 
have no idea how to produce those types of images from code.


--
Terry Jan Reedy


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


Re: Python use growing fast

2011-01-10 Thread Dan Stromberg
On Mon, Jan 10, 2011 at 2:29 PM, John Nagle  wrote:
> On 1/10/2011 1:02 PM, MRAB wrote:
>>
>> On 10/01/2011 20:29, Dan Stromberg wrote:
>>>
>>> I invite folks to check out Tiobe's Language Popularity Rankings:
>>>
>>> http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
>
>   That's somehow derived from web searches, not from any real data
> source.  Look how far down JavaScript is.

Please define "real data source", and give examples...  ^_^
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: String to char and decimal number conversion

2011-01-10 Thread SANKAR .
Hi Chris ,

Thanks for your response.

I am reading a Test.txt (see atatchment) file using following code to get
the T2:

F =open('C:\Test.txt','r')
T1 = F.readlines()
for i in range(len(T1)):
   T2 = T1[i].split(',')
   print(T2)


Regards
Sankar

On Tue, Jan 11, 2011 at 10:02 AM, Chris Rebert  wrote:

>  On Mon, Jan 10, 2011 at 2:44 PM, SANKAR .  wrote:
> > Hello There,
> >
> >I am from non IT field also new to python programming.Could you
> > please help me to solve the following problem?
> >
> > I have a list T1 with following format:
> >
> > T1 = [ ' "Field" ' , ' "12.5" ', ' "2.5" ']
> >
> > How do get the list elements without double quote in my output (T2).
> >
> > T2 =[ ' Field ' , ' 12.5 ', ' 2.5 ']
>
> How are you obtaining T1 in the first place?
>
> Cheers,
> Chris
> --
> http://blog.rebertia.com
>
{\rtf1\ansi\ansicpg1252\deff0\deflang3081{\fonttbl{\f0\fnil\fcharset0 Courier 
New;}{\f1\fswiss\fcharset0 Arial;}}
{\*\generator Msftedit 5.41.15.1515;}\viewkind4\uc1\pard\f0\fs20 
"FIELD_DEF","Site 
01","","0","","28.89","179.00","","M1Synergy","Fixed","Xrays","6","","600","100.0","86.6","0.0","180.0","ASY","0.0","-8.0","7.9","ASY","0.0","-5.5","5.5","","","","0.0","0.0","","","","","","","","","","","","","","","","","","57636"\par
"CONTROL_PT_DEF","0","2","40","28","0","1","0.00","","6","600","86.6","2","0.0","","180.0","","ASY","0.0","-8.0","7.9","ASY","0.0","-5.5","5.5","0.0","0.0","","0.0","","0.0","","-2.25","-2.25","-2.25","-2.25","-2.25","-2.25","-2.25","-2.25","-2.25","-2.25","-2.25","-2.25","-2.25","-2.25","-5.53","-6.52","-7.04","-7.50","-8.00","-8.00","-4.85","-4.66","-5.84","-5.97","-5.91","-6.43","0.25","0.25","0.25","0.25","0.25","0.25","0.25","0.25","0.25","0.25","0.25","0.25","0.25","0.25","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","-1.75","-1.75","-1.75","-1.75","-1.75","-1.75","-1.75","-1.75","-1.75","-1.75","-1.75","-1.75","-1.75","-1.75","0.98","5.55","6.36","6.78","6.75","6.86","7.08","7.81","7.65","7.73","6.97","7.49","0.75","0.75","0.75","0.75","0.75","0.75","0.75","0.75","0.75","0.75","0.75","0.75","0.75","0.75","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","30539"\par
"CONTROL_PT_DEF","0","2","40","28","1","1","0.084884","","","","","2","","","","","ASY","0.0","-8.0","7.9","ASY","0.0","-5.5","5.5","0.0","0.0","","0.0","","0.0","","-2.25","-2.25","-2.25","-2.25","-2.25","-2.25","-2.25","-2.25","-2.25","-2.25","-2.25","-2.25","-2.25","-2.25","-5.53","-6.52","-7.04","-7.50","-8.00","-8.00","-4.85","-4.66","-5.84","-5.97","-5.91","-6.43","0.25","0.25","0.25","0.25","0.25","0.25","0.25","0.25","0.25","0.25","0.25","0.25","0.25","0.25","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","-1.75","-1.75","-1.75","-1.75","-1.75","-1.75","-1.75","-1.75","-1.75","-1.75","-1.75","-1.75","-1.75","-1.75","0.98","5.55","6.36","6.78","6.75","6.86","7.08","7.81","7.65","7.73","6.97","7.49","0.75","0.75","0.75","0.75","0.75","0.75","0.75","0.75","0.75","0.75","0.75","0.75","0.75","0.75","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","61090"\par
\f1\par
}
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Absolute imports?

2011-01-10 Thread Ben Finney
Ben Finney  writes:

> The filesystem path (if any!) is derived from the name that the module
> will be bound to within the code. That'w why the indirection of
> ‘sys.path’ is necessary: it keeps the mapping between module names and
> filesystem paths.

That phrasing gives the wrong impression; ‘sys.path’ doesn't store that
mapping. I meant only that the indirection of ‘sys.path’ is necessary to
allow Python to maintain that mapping at import time.

-- 
 \ “This world in arms is not spending money alone. It is spending |
  `\  the sweat of its laborers, the genius of its scientists, the |
_o__)   hopes of its children.” —Dwight Eisenhower, 1953-04-16 |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What INI config file module allows lists of duplicate same-named options?

2011-01-10 Thread Philip Semanchuk

On Jan 10, 2011, at 6:05 PM, Ben Finney wrote:

> "Thomas L. Shinnick"  writes:
> 
>> Here, I need to list multiple file/dir path pairs.  A list of multiple
>> items to be acted upon in a common way.  It is a list.  Simple.
>> Except I can't find a library/pypi module with the obvious extension.
> 
> What you want is incompatible with calling the result “an INI file”,
> because that entails the restrictions you described.

I dunno about that. The INI file format isn't standardized so there aren't 
restrictions on what one can expect to find in an INI file other than people's 
expectations. I'll grant you that most INI files don't have (or expect) 
duplicate keys in a section, but I've seen some that do.


> You would be better advised to use a configuration format that can do
> what you want, such as YAML or JSON. Both of those have good Python
> support; JSON in particular has support in the standard library.

I second that, and the point above (about there being no standard that governs 
INI files) is another reason to avoid them. Some INI file libraries expect a 
hash mark as a comment, some expect semicolon, some make no allowances for 
non-ASCII encodings, some expect UTF-8 or ISO-8859-1 or Win-1252, some only 
allow '=' as the key/value separator, some allow other characters. INI files 
are nice and simple but there's devils in those details.

Cheers
Philip

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


Re: What INI config file module allows lists of duplicate same-named options?

2011-01-10 Thread Ben Finney
"Thomas L. Shinnick"  writes:

> Here, I need to list multiple file/dir path pairs.  A list of multiple
> items to be acted upon in a common way.  It is a list.  Simple.
> Except I can't find a library/pypi module with the obvious extension.

What you want is incompatible with calling the result “an INI file”,
because that entails the restrictions you described.

You would be better advised to use a configuration format that can do
what you want, such as YAML or JSON. Both of those have good Python
support; JSON in particular has support in the standard library.

-- 
 \  “Saying that Java is nice because it works on all OSes is like |
  `\ saying that anal sex is nice because it works on all genders” |
_o__)—http://bash.org/ |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Absolute imports?

2011-01-10 Thread Ben Finney
Roy Smith  writes:

>  Ben Finney  wrote:
> > What is the problem you're trying to solve? It is likely we can
> > suggest a better solution.
>
> Well, the problem I'm trying to solve is that I have an absolute
> pathname to a python source file that I want to import as a module :-)

And then have it available in the code under what name?

It is important to realise that ‘import’ does many things. Among the
many things it does (see the Python documentation for more) it executes
the code within a namespace, and then binds that namespace to a name
that is specified in the ‘import’ statement.

The filesystem path (if any!) is derived from the name that the module
will be bound to within the code. That'w why the indirection of
‘sys.path’ is necessary: it keeps the mapping between module names and
filesystem paths.

> The best I can describe how to find the location of the config file is, 
> "Work your way up the directory tree from where you are now, (i.e. 
> following '..' links) until you get to the top level of the project, 
> then from there, it's ./code/configs/autogen/config.py."

One way to keep the import mechanism working with that situation would
be to:

* compute the path:   ‘config_dir_path = your_algorithm_above()’
* add the path to the search list:  ‘sys.path.append(config_dir_path)’
* import the config module:  ‘import config’

The module is then available under the name ‘config’.

> It's reasonably straight-forward to figure out that absolute path,
> starting from sys.argv[0] and using the tools in os.path. Now I need
> to import the file, given that I know its absolute pathname. It looks
> like imp.load_source() does what I want, I'm just wondering if there's
> a cleaner way.

I think ‘imp.load_source’ is not as clean as the steps I describe above,
given the rest of the ‘import’ job that needs to be done.

Given that modules in Python form a namespace hierarchy, it's unusual
and discouraged to import files from arbitrary parts of the filesystem.

-- 
 \ “I must say that I find television very educational. The minute |
  `\   somebody turns it on, I go to the library and read a book.” |
_o__)—Groucho Marx |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python use growing fast

2011-01-10 Thread Chris Rebert
On Mon, Jan 10, 2011 at 2:29 PM, John Nagle  wrote:
> On 1/10/2011 1:02 PM, MRAB wrote:
>>
>> On 10/01/2011 20:29, Dan Stromberg wrote:
>>>
>>> I invite folks to check out Tiobe's Language Popularity Rankings:
>>>
>>> http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
>
>   That's somehow derived from web searches, not from any real data
> source.  Look how far down JavaScript is.

Also depends on how one defines "popularity" in the context of
programming languages.

Cheers,
Chris
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: String to char and decimal number conversion

2011-01-10 Thread Chris Rebert
On Mon, Jan 10, 2011 at 2:44 PM, SANKAR .  wrote:
> Hello There,
>
>    I am from non IT field also new to python programming.Could you
> please help me to solve the following problem?
>
> I have a list T1 with following format:
>
> T1 = [ ' "Field" ' , ' "12.5" ', ' "2.5" ']
>
> How do get the list elements without double quote in my output (T2).
>
> T2 =[ ' Field ' , ' 12.5 ', ' 2.5 ']

How are you obtaining T1 in the first place?

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


String to char and decimal number conversion

2011-01-10 Thread SANKAR .
Hello There,

   I am from non IT field also new to python programming.Could you
please help me to solve the following problem?

I have a list T1 with following format:

T1 = [ *' "*Field*" **' , ' "*12.5*" **', ' "*2.5*" ']*
* *
How do get the list elements without double quote in my output (T2).

T2 =[ *' *Field* **' , ' *12.5 *', ' *2.5* ']*



Thanks

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


Centering a window

2011-01-10 Thread Rohit Coder

I am using PyQt4 for GUI apps.
I created a class that contains a function to center any window (Form) whose 
name is passed to this class. I have two questions:
How to modify the below given code to center the window whose name we passed as 
an argument.How to pass window name to this class from another file that 
imports this class?
= CODE BLOCK STARTS HERE ===from PyQt4 import QtGui
class PositionWindow:def __init__(self, xCoord, yCoord, windowName, parent 
= None):  self.x = xCoord  self.y = yCoord  self.wName = 
windowName;def center(self):screen = 
QtGui.QDesktopWidget().screenGeometry()size = self.geometry()
self.move((screen.width()-size.width())/2, 
(screen.height()-size.height())/2)= CODE BLOCK ENDS HERE ===
Rohit 
K.elementFontfont-familyfont-sizefont-stylefont-variantfont-weightletter-spacingline-heighttext-decorationtext-aligntext-indenttext-transformwhite-spaceword-spacingcolorBackgroundbg-attachmentbg-colorbg-imagebg-positionbg-repeatBoxwidthheightborder-topborder-rightborder-bottomborder-leftmarginpaddingmax-heightmin-heightmax-widthmin-widthoutline-coloroutline-styleoutline-widthPositioningpositiontopbottomrightleftfloatdisplayclearz-indexListlist-style-imagelist-style-typelist-style-positionTablevertical-alignborder-collapseborder-spacingcaption-sideempty-cellstable-layoutEffectstext-shadow-webkit-box-shadowborder-radiusOtheroverflowcursorvisibility
  -- 
http://mail.python.org/mailman/listinfo/python-list


Compiling and Executing a Python byte coded program

2011-01-10 Thread A famous IT technical writer
If interested with, have a look to
http://vouters.dyndns.org/tima/All-OS-Python-Compiling_a_Python_Program_and_Executing_the_compiled_version.html

Note you may boost your Python's startup time but not the execution
speed of your program which depends on the generated byte code.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python use growing fast

2011-01-10 Thread John Nagle

On 1/10/2011 1:02 PM, MRAB wrote:

On 10/01/2011 20:29, Dan Stromberg wrote:

I invite folks to check out Tiobe's Language Popularity Rankings:

http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html


   That's somehow derived from web searches, not from any real data
source.  Look how far down JavaScript is.

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


Re: Python use growing fast

2011-01-10 Thread Krzysztof Bieniasz
> I invite folks to check out Tiobe's Language Popularity Rankings:
> 
> http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html
> 
> The gist is: Python grew faster than any other programming language over
> the last year, according to this (slightly arbitrary, but better than no
> indicator) ranking.

And look at the Hall of Fame. Python is the first language to win the 
popularity award twice. Although the statistical population isn't really 
extensive...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python use growing fast

2011-01-10 Thread Alice Bevan–McGregor

On 2011-01-10 13:02:09 -0800, MRAB said:

On 10/01/2011 20:29, Dan Stromberg wrote:
...despite our wikipedia page whose first paragraph almost seems like 
it was written with the intention of scaring off new converts, with its 
"unusual" comment...


Indentation as a syntatitical structure is not actually unusual in any 
way as was recently discussed in another thread (having difficulty 
finding it).



It shows an example of Python code, which happens to have 2 syntax errors!


Wikipedia is a Wiki; everyone is free to contribute and correct mistakes.

- Alice.



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


Re: Resolve circular reference

2011-01-10 Thread moerchendiser2k3
On Jan 10, 7:18 pm, Stefan Behnel  wrote:
> moerchendiser2k3, 10.01.2011 18:55:
>
> >> If you can tell us why it's so important that the object be destroyed
> >> at that given time, even while a reference to it exists, maybe we can
> >> give you better suggestions.
>
> > Thanks for your answer! In my case the types A and B (in my example
> > above)
> > are a dialog and a dialog widget. At a special time I have to close
> > and
> > destroy all dialogs but this does not happen because the widget keeps
> > the dialog alive. I have the reference to the dialog
> > but after I closed the dialogs I also would like to destroy them
> > because they have to free some special ressources.
>
> Objects within a reference cycle will eventually get cleaned up, just not
> right away and not in a predictable order.
>
> If you need immediate cleanup, you should destroy the reference cycle
> yourself, e.g. by removing the widgets from the dialog when closing it.
>
> Stefan

The PyWidget type does not own the widget, it just points to it. I
have an
idea, would this fix the problem?

I destroy the internal dictionary of the dialog which points to other
PyObjects?
Then I would cut the dependency.

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


Re: Python use growing fast

2011-01-10 Thread MRAB

On 10/01/2011 20:29, Dan Stromberg wrote:

I invite folks to check out Tiobe's Language Popularity Rankings:

http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html

The gist is: Python grew faster than any other programming language
over the last year, according to this (slightly arbitrary, but better
than no indicator) ranking.

...despite our wikipedia page whose first paragraph almost seems like
it was written with the intention of scaring off new converts, with
its "unusual" comment:

http://en.wikipedia.org/wiki/Python_%28programming_language%29

(Like it or not, people do frequently confuse the descriptive for the normative)


It shows an example of Python code, which happens to have 2 syntax
errors!
--
http://mail.python.org/mailman/listinfo/python-list


arbeitsamt jobs ausland , stellenangebot in ausland , Berufskraftfahrer Berufskraftfahrerin , Maler Malerin , stellenanzeigen jobboerse , arbeitsvermittlung , Meteorologe Meteorologin , jobs und prakt

2011-01-10 Thread http://groups.google.com/group/de.comp.os.os2.apps/post
arbeitsamt jobs ausland , stellenangebot in ausland ,
Berufskraftfahrer Berufskraftfahrerin , Maler Malerin ,
stellenanzeigen jobboerse , arbeitsvermittlung , Meteorologe
Meteorologin , jobs und praktika im ausland 2007 , Innenarchitekt
Innenarchitektin ,

+
+
+
+++ TOPJOB AUSLAND +++ IM AUSLAND ARBEITEN +++
+
+
http://WWW.AUSLANDS-JOB.ORG
http://WWW.AUSLANDS-JOB.ORG
http://WWW.AUSLANDS-JOB.ORG
http://WWW.AUSLANDS-JOB.ORG
http://WWW.AUSLANDS-JOB.ORG
http://WWW.AUSLANDS-JOB.ORG
+
+
+
+
+
+
+
+


ehrenamtlich arbeiten im ausland Polizeivollzugsbeamte
Polizeivollzugsbeamter
Mediengestalter Bild und Ton www ausland jobs
stellenangebote fuers ausland ausland jobs de
jobboerse angebote stellenanzeigen ausland
außendienstmitarbeiter jobs im ausland australien
jobboersen ausland berufe ausland
Maurer Maurerin arbeiten im ausland steuern
Tieraerztin Tierarzt auswandern jobs im ausland
praktikum im ausland Event-Manager Event-Managerin
Industriemechaniker Industriemechanikerin jobsuche jobboerse
Restaurantfachfrau Restaurantfachmann Journalist Journalistin
will im ausland arbeiten jobangebote ausland
jobboerse arbeitgeber Personalreferent Personalreferentin
jobboerse bayern Kauffrau audiovisuelle Medien
www arbeiten im ausland Hebamme
-- 
http://mail.python.org/mailman/listinfo/python-list


Python use growing fast

2011-01-10 Thread Dan Stromberg
I invite folks to check out Tiobe's Language Popularity Rankings:

http://www.tiobe.com/index.php/content/paperinfo/tpci/index.html

The gist is: Python grew faster than any other programming language
over the last year, according to this (slightly arbitrary, but better
than no indicator) ranking.

...despite our wikipedia page whose first paragraph almost seems like
it was written with the intention of scaring off new converts, with
its "unusual" comment:

http://en.wikipedia.org/wiki/Python_%28programming_language%29

(Like it or not, people do frequently confuse the descriptive for the normative)
-- 
http://mail.python.org/mailman/listinfo/python-list


[ANN] cdecimal-2.2 released

2011-01-10 Thread Stefan Krah
Hi,

I'm pleased to announce the release of cdecimal-2.2. cdecimal is a fast
drop-in replacement for the decimal module in Python's standard library.


Blurb
=

cdecimal is a complete implementation of IBM's General Decimal Arithmetic
Specification. With the appropriate context parameters, cdecimal will also
conform to the IEEE 754-2008 Standard for Floating-Point Arithmetic.

Typical performance gains over decimal.py are between 30x for I/O heavy
benchmarks and 80x for numerical programs. In a PostgreSQL database
benchmark, the speedup is 12x.

+-+-+--+-+
| |   decimal   |   cdecimal   |   speedup   |
+=+=+==+=+
|   pi|42.75s   |0.58s | 74x |
+-+-+--+-+
| telco   |   172.19s   |5.68s | 30x |
+-+-+--+-+
| psycopg | 3.57s   |0.29s | 12x |
+-+-+--+-+


In the pi benchmark, cdecimal often performs better than Java's BigDecimal
running on Java HotSpot(TM) 64-Bit Server VM.


Both cdecimal and the underlying library - libmpdec - have very large
test suites. libmpdec has 100% code coverage, cdecimal 85%. The test
suites have been running continuously for over a year without any
major issues.


Install
===

Since cdecimal is now listed on PyPI, it can be installed using pip:

pip install cdecimal


Windows installers are available at:

http://www.bytereef.org/mpdecimal/download.html


Links
=

http://www.bytereef.org/mpdecimal/index.html
http://www.bytereef.org/mpdecimal/changelog.html
http://www.bytereef.org/mpdecimal/download.html


Checksums of the released packages
==

sha256sum
-

3d92429fab74ddb17d12feec9cd949cd8a0be4bc0ba9afc5ed9b3af884e5d406  
mpdecimal-2.2.tar.gz
e8f02731d4089d7c2b79513d01493c36ef41574423ea3e49b245b86640212bdc  
mpdecimal-2.2.zip
515625c5c5830b109c57af93d49ae2c57ec3f230d46a3e0583840ff73d7963be  
cdecimal-2.2.tar.gz


sha1sum
---

24695b2c9254e1b870eb663e3d966eb4f0abd5ab  cdecimal-2.2.win32-py2.6.msi
e74cb7e722f30265b408b322d2c50d9a18f78587  cdecimal-2.2.win32-py2.7.msi
7c39243b2fc8b1923ad6a6066536982844a7617f  cdecimal-2.2.win32-py3.1.msi
5711fd69a8e1e2e7be0ad0e6b93ecc10aa584c68  cdecimal-2.2.win-amd64-py2.6.msi
b1cd7b6a373c212bf2f6aa288cd767171bfefd41  cdecimal-2.2.win-amd64-py2.7.msi
f08a803a1a42a2d8507da1dc49f3bf7eed37c332  cdecimal-2.2.win-amd64-py3.1.msi

cb29fa8f67befaf2d1a05f4675f840d7cd35cf6c  cdecimal-2.2-no-thread.win32-py2.6.msi
012a44488f2ce2912f903ae9faf995efc7c9324b  cdecimal-2.2-no-thread.win32-py2.7.msi
1c08c73643fc45d7b0feb62c33bebd76537f9d02  cdecimal-2.2-no-thread.win32-py3.1.msi
b6dbd92e86ced38506ea1a6ab46f2e41f1444eae  
cdecimal-2.2-no-thread.win-amd64-py2.6.msi
b239b41e6958d9e71e91b122183dc0eaefa00fef  
cdecimal-2.2-no-thread.win-amd64-py2.7.msi
413724ff20ede7b648f57dd9a78a12e72e064583  
cdecimal-2.2-no-thread.win-amd64-py3.1.msi



Stefan Krah



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


Re: Print to an IPP printer (pkipplib?)

2011-01-10 Thread Adam Tauno Williams
On Mon, 2011-01-10 at 10:49 -0800, Emile van Sebille wrote: 
> On 1/10/2011 10:40 AM Adam Tauno Williams said...
> > First I have to make a text stream into a PDF, so I have something to
> > send. Surprisingly I've been able to find no code to steal which does
> > that; which means it will take longer. :(
> reportlab?

Possibly, there is that an pyPdf.  I've found
 recently, but haven't had time
to take it apart yet [and the license looks OK, other code snippets I've
found were explicitly GPL so I couldn't look at those].

> [clumsily thunking out to
> > commands like "a2ps", etc... is strictly forbidden in this code-base;
> > and that seems how a lot of people seem to hand it].


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


Re: Print to an IPP printer (pkipplib?)

2011-01-10 Thread Emile van Sebille

On 1/10/2011 10:40 AM Adam Tauno Williams said...

First I have to make a text stream into a PDF, so I have something to
send. Surprisingly I've been able to find no code to steal which does
that; which means it will take longer. :(


reportlab?

[clumsily thunking out to

commands like "a2ps", etc... is strictly forbidden in this code-base;
and that seems how a lot of people seem to hand it].




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


Re: Print to an IPP printer (pkipplib?)

2011-01-10 Thread Adam Tauno Williams
On Mon, 2011-01-10 at 10:37 -0700, Michael Torrie wrote: 
> On 10/16/2010 10:49 AM, Adam Tauno Williams wrote:
> > I've found the module pkipplib which seems to work well for things like
> > interrogating an IPP (CUPS) server.  But is there a way to send a print
> > job to an IPP print queue? [and no, the local system knows nothing about
> > the print architecture so popenlp is not an option].  I just want to
> > send the data from a file handle to a remote IPP queue as a print job.
> I wonder if you could post the print job directly to the IPP url.  It's
> really just HTTP under the hood.

Correct; I've been meaning to try that but haven't gotten back to it on
my to-do list.  

First I have to make a text stream into a PDF, so I have something to
send. Surprisingly I've been able to find no code to steal which does
that; which means it will take longer. :(  [clumsily thunking out to
commands like "a2ps", etc... is strictly forbidden in this code-base;
and that seems how a lot of people seem to hand it].

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


Re: Resolve circular reference

2011-01-10 Thread Stefan Behnel

moerchendiser2k3, 10.01.2011 18:55:

If you can tell us why it's so important that the object be destroyed
at that given time, even while a reference to it exists, maybe we can
give you better suggestions.


Thanks for your answer! In my case the types A and B (in my example
above)
are a dialog and a dialog widget. At a special time I have to close
and
destroy all dialogs but this does not happen because the widget keeps
the dialog alive. I have the reference to the dialog
but after I closed the dialogs I also would like to destroy them
because they have to free some special ressources.


Objects within a reference cycle will eventually get cleaned up, just not 
right away and not in a predictable order.


If you need immediate cleanup, you should destroy the reference cycle 
yourself, e.g. by removing the widgets from the dialog when closing it.


Stefan

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


Re: os.system and loggers

2011-01-10 Thread Carl Banks
On Jan 10, 8:29 am, Tim  wrote:
> I think I may have included too much fluff in my original question.
> The main thing I wonder is whether I can attach a log handler to
> stdout in such a way that os.system calls will write to that handler
> instead of the console.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: os.system and loggers

2011-01-10 Thread Carl Banks
On Jan 10, 8:29 am, Tim  wrote:
> On Jan 7, 11:24 am, Tim  wrote:
>
>
>
>
>
> > hi, I'm using a 3rd-party python program that uses the python logging
> > facility and also makes calls to os.system. I'm trying to capture its
> > output to a file.
>
> > In my own code, I've taken control of the loggers that are setup in
> > the other program by removing its StreamHandler and replacing with
> > FileHander. But when it comes to the call to os.system I'm at a loss.
>
> > I want to capture the stdout from that os.system call in my
> > FileHandler. I thought this might work, before I call the other
> > program's class/method:
> > sys.stdout = getLogger('status').handlers[0].stream
>
> > but no dice. Is there any clean way to get what I want? If not, I
> > guess I'll override the other method with my own, but it will
> > basically be a bunch of code copied with os.sytem replaced with
> > subprocess, using getLogger('status').handlers[0].stream for stdout/
> > stderr.
>
> > thanks,
> > --Tim Arnold
>
> Replying to my own post
>
> I think I may have included too much fluff in my original question.
> The main thing I wonder is whether I can attach a log handler to
> stdout in such a way that os.system calls will write to that handler
> instead of the console.

No, but you could replace os.system with something that does work.
(It would replace it globally for all uses, so you may need some logic
to decide whether to leave the call alone, or to modify it, perhaps by
inspecting the call stack.)

The simplest thing to do is to append a shell redirection to the
command (>/your/log/file), so something like this:

_real_os_system = os.system

def my_os_system(cmd):
if test_log_condition:
return _real_os_system(cmd + "2> /my/log/file")
return _real_os_system(cmd)

os.system = my_os_system

That could backfire for any number of reasons so you probably should
only do this if you know that it works with all the commands it
issues.

The better way might be to call the subprocess module instead, where
you can dispatch the command with redirection to any stream.  I doubt
there's a foolproof way to do that given an arbitrary os.system
command, but the subprocess way is probably safer.


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


Re: Resolve circular reference

2011-01-10 Thread moerchendiser2k3
> If you can tell us why it's so important that the object be destroyed
> at that given time, even while a reference to it exists, maybe we can
> give you better suggestions.

Thanks for your answer! In my case the types A and B (in my example
above)
are a dialog and a dialog widget. At a special time I have to close
and
destroy all dialogs but this does not happen because the widget keeps
the dialog alive. I have the reference to the dialog
but after I closed the dialogs I also would like to destroy them
because
they have to free some special ressources.

Thanks a lot!! Bye, moerchendiser2k3
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Print to an IPP printer (pkipplib?)

2011-01-10 Thread Michael Torrie
On 10/16/2010 10:49 AM, Adam Tauno Williams wrote:
> I've found the module pkipplib which seems to work well for things like
> interrogating an IPP (CUPS) server.  But is there a way to send a print
> job to an IPP print queue? [and no, the local system knows nothing about
> the print architecture so popenlp is not an option].  I just want to
> send the data from a file handle to a remote IPP queue as a print job.

I wonder if you could post the print job directly to the IPP url.  It's
really just HTTP under the hood.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PJL

2011-01-10 Thread Emile van Sebille

On 1/10/2011 7:06 AM loial said...

Thanks for responding..

First question...how do I send it to the printer?   Printer would be
on the network.


Start here: 
http://mail.python.org/pipermail/python-announce-list/2000-November/000567.html


The middle article covers accessing the printer.

Emile


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


Re: os.system and loggers

2011-01-10 Thread Tim
On Jan 7, 11:24 am, Tim  wrote:
> hi, I'm using a 3rd-party python program that uses the python logging
> facility and also makes calls to os.system. I'm trying to capture its
> output to a file.
>
> In my own code, I've taken control of the loggers that are setup in
> the other program by removing its StreamHandler and replacing with
> FileHander. But when it comes to the call to os.system I'm at a loss.
>
> I want to capture the stdout from that os.system call in my
> FileHandler. I thought this might work, before I call the other
> program's class/method:
> sys.stdout = getLogger('status').handlers[0].stream
>
> but no dice. Is there any clean way to get what I want? If not, I
> guess I'll override the other method with my own, but it will
> basically be a bunch of code copied with os.sytem replaced with
> subprocess, using getLogger('status').handlers[0].stream for stdout/
> stderr.
>
> thanks,
> --Tim Arnold

Replying to my own post

I think I may have included too much fluff in my original question.
The main thing I wonder is whether I can attach a log handler to
stdout in such a way that os.system calls will write to that handler
instead of the console.

thanks,
--Tim
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PJL

2011-01-10 Thread Wolfgang Rohdewald
On Montag 10 Januar 2011, loial wrote:
> First question...how do I send it to the printer?   Printer
> would be on the network.

echo PJL | lp -oraw -dnetworkprinter

if it works, translate it to python

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


Re: Resolve circular reference

2011-01-10 Thread Carl Banks
On Jan 10, 12:21 am, moerchendiser2k3  wrote:
> so there is no chance without using weakrefs?
> any ideas, tips, workarounds how I might handle this?

No, sorry: as long as a reference to an object exists, the object is
never deleted.  There is no way to get around this.

Python in general isn't designed to allow for exact control over the
destruction of objects.  Even in CPython, which uses reference
counting, there are a bunch of situations where a reference might be
stored to an object that keeps it alive.  (Unexpected locations where
a stray reference might exist: an unpickler object, the _ symbol in
the interactive shell.)  Other implementations, like Jython and
IronPython, don't use reference counting and don't provide for any
particular time at all for an object to be destroyed.

The recommended way to ensure timely release of resources in Python is
to provide a method (such as close or finalize) to explicity release
the resource--the object then lives on in a zombie state.  The with
statement can be used in many cases to avoid the need to call this
method explicitly.  For example, if you were to run this code in
Python:

with open(filename) as f:
g = f
print g

It would print .  The object still exists
because there is a reference to it, but the file has been closed.


If you can tell us why it's so important that the object be destroyed
at that given time, even while a reference to it exists, maybe we can
give you better suggestions.


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


Re: PJL

2011-01-10 Thread loial
Thanks for responding..

First question...how do I send it to the printer?   Printer would be
on the network.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Create a class to position a window on the screen.

2011-01-10 Thread Zac Burns
I'm not exactly sure what you are asking here, but one problem that is
notable in your example is that the center function is indented inside the
__init__ function. This would create a closure instead of a method on
PositionWindow, which is probably not what you want.

-Zac



On Sun, Jan 9, 2011 at 10:23 AM, Rohit Coder <
passionate_program...@hotmail.com> wrote:

>  Hi,
> elementFontfont-familyfont-sizefont-stylefont-variantfont-weight
> letter-spacingline-heighttext-decorationtext-aligntext-indent
> text-transformwhite-spaceword-spacingcolorBackgroundbg-attachmentbg-color
> bg-imagebg-positionbg-repeatBoxwidthheightborder-topborder-right
> border-bottomborder-leftmarginpaddingmax-heightmin-heightmax-width
> min-widthoutline-coloroutline-styleoutline-widthPositioningpositiontop
> bottomrightleftfloatdisplayclearz-indexListlist-style-imagelist-style-type
> list-style-positionTablevertical-alignborder-collapseborder-spacing
> caption-sideempty-cellstable-layoutEffectstext-shadow-webkit-box-shadow
> border-radiusOtheroverflowcursorvisibility
>
> I am new to Python and this is my fist Python class. I am using PyQt4
> framework on Windows 7.
>
> I don't know whether the code below is correctly written or not. I want to
> modify it further as:
>
>  1. In the arguments, I want to pass the name of another opened Window
> (.py) on the screen.
>  2. I want to pass the x-coord., y-coord. and the name of the window to
> position on the screen.
>
> How to modify the code to fulfill these requirements?
>
> ***Attempted Code***
>
> class PositionWindow:
> def __init__(self, xCoord, yCoord, windowName, parent = None):
>   self.x = xCoord
>   self.y = yCoord
>   self.wName = windowName;
>
>   def center(self):
> screen = QtGui.QDesktopWidget().screenGeometry()
> size = self.geometry()
> self.move((screen.width()-size.width())/2,
> (screen.height()-size.height())/2)
>
> ...
> Rohit.
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PJL

2011-01-10 Thread Emile van Sebille

On 1/10/2011 6:12 AM loial said...

Anyone got any experience of send PJL commands to a printer using
Python on Unix?



Are you having trouble?  PJL is sent like any other text...

Emile

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


Re: Close stdout socket on CGI after fork with subprocess

2011-01-10 Thread Thibaud Roussillat
On Mon, Jan 10, 2011 at 9:26 AM, Kushal Kumaran <
kushal.kumaran+pyt...@gmail.com > wrote:

> On Mon, Jan 10, 2011 at 1:15 PM, Thibaud Roussillat
>  wrote:
> > On Sat, Jan 8, 2011 at 3:19 AM, Kushal Kumaran
> > >
> wrote:
> >>
> >> On Fri, Jan 7, 2011 at 8:08 PM, Thibaud Roussillat
> >>  wrote:
> >> > Hi,
> >> >
> >> > I work with Python 2.4 and CGI.
> >> >
> >> > I have a CGI which call a Python script in background process and
> return
> >> > result before background task is finished.
> >> >
> >> > Actually, the browser displays response but it is waiting for end of
> >> > background task because the socket is not closed.
> >> >
> >> > Internet told me that I must close the stdout file descriptor
> >> > (sys.stdout.close()) to close the socket but it doesn't work.
> >> >
> >> > The background task is launched via subprocess.Popen and is attached
> to
> >> > the
> >> > root process on ps command.
> >> >
> >>
> >> This means that the parent process finished before the child.  Call
> >> wait() on the Popen object to wait for the child to terminate.
> >> Depending on how you create the Popen object, the child process may
> >> inherit your own stdout.  In that case, the child process may be
> >> keeping the socket open after the parent dies.
> >>
> >
> > 
> >
> > In fact, the parent process finished before the child, it's why I want to
> > run the child in a forked process, and close the socket of the parent
> task.
> >
> > The goal is not to wait for the child process but to leave it lead one's
> own
> > life as a background task. The client don't have to wait for the end of
> the
> > child process.
> >
> > Is there a way to not inherit from the parent stdout on the child process
> ?
> >
>
> open os.devnull and pass that file object as stdin, stdout and stderr
> for the child process.  Hopefully the program you are running has been
> designed not to expect to be able to use stdin/stdout/stderr.
>
> Please keep the discussion on the mailing list.  Other people on the
> list are smarter than me.  Also, the convention on this mailing list
> is to keep replies below the quoted content.
>
> --
> regards,
> kushal
>

Thanks a lot, this works well with a file object opened on /dev/null (or
os.devnull) and passed as stdin, stdout and stderr.

Sorry for the reply, I just do "reply" on my webmail ;)

Regards,

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


PJL

2011-01-10 Thread loial
Anyone got any experience of send PJL commands to a printer using
Python on Unix?

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


Re: Absolute imports?

2011-01-10 Thread Jean-Michel Pichavant

Roy Smith wrote:

[snip]
It's reasonably straight-forward to figure out that absolute path, 
starting from sys.argv[0] and using the tools in os.path.  Now I need to 
import the file, given that I know its absolute pathname.  It looks like 
imp.load_source() does what I want, I'm just wondering if there's a 
cleaner way.
  


What about

config = __import__(configPath.replace('.py', ''))


JM

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


Re: Close stdout socket on CGI after fork with subprocess

2011-01-10 Thread Kushal Kumaran
On Mon, Jan 10, 2011 at 1:15 PM, Thibaud Roussillat
 wrote:
> On Sat, Jan 8, 2011 at 3:19 AM, Kushal Kumaran
>  wrote:
>>
>> On Fri, Jan 7, 2011 at 8:08 PM, Thibaud Roussillat
>>  wrote:
>> > Hi,
>> >
>> > I work with Python 2.4 and CGI.
>> >
>> > I have a CGI which call a Python script in background process and return
>> > result before background task is finished.
>> >
>> > Actually, the browser displays response but it is waiting for end of
>> > background task because the socket is not closed.
>> >
>> > Internet told me that I must close the stdout file descriptor
>> > (sys.stdout.close()) to close the socket but it doesn't work.
>> >
>> > The background task is launched via subprocess.Popen and is attached to
>> > the
>> > root process on ps command.
>> >
>>
>> This means that the parent process finished before the child.  Call
>> wait() on the Popen object to wait for the child to terminate.
>> Depending on how you create the Popen object, the child process may
>> inherit your own stdout.  In that case, the child process may be
>> keeping the socket open after the parent dies.
>>
>
> 
>
> In fact, the parent process finished before the child, it's why I want to
> run the child in a forked process, and close the socket of the parent task.
>
> The goal is not to wait for the child process but to leave it lead one's own
> life as a background task. The client don't have to wait for the end of the
> child process.
>
> Is there a way to not inherit from the parent stdout on the child process ?
>

open os.devnull and pass that file object as stdin, stdout and stderr
for the child process.  Hopefully the program you are running has been
designed not to expect to be able to use stdin/stdout/stderr.

Please keep the discussion on the mailing list.  Other people on the
list are smarter than me.  Also, the convention on this mailing list
is to keep replies below the quoted content.

-- 
regards,
kushal
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Resolve circular reference

2011-01-10 Thread moerchendiser2k3
so there is no chance without using weakrefs?
any ideas, tips, workarounds how I might handle this?

bye, moerchendiser2k3
-- 
http://mail.python.org/mailman/listinfo/python-list