Re: PEP 391 (Dictionary-Based Configuration for Logging) Updated

2009-10-28 Thread Wolodja Wentland
On Wed, Oct 28, 2009 at 10:27 +, Vinay Sajip wrote:
 I've updated PEP 391 (Dictionary-Based Configuration for Logging):
 http://svn.python.org/view/peps/trunk/pep-0391.txt?r1=75599r2=75918
+1

 All feedback gratefully received!

The PEP does not seem to specify how handler are retrieved by their
name/id. How should this work? Especially given the statement:

The handler name lookup dictionary is for configuration use only
 and will not become part of the public API for the package.

thanks for incorporating these changes.

Wolodja


signature.asc
Description: Digital signature
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IDLE python shell freezes after running show() of matplotlib

2009-10-28 Thread OKB (not okblacke)
Forrest Sheng Bao wrote:

 I am having a weird problem on IDLE. After I plot something using show
 () of matplotlib, the python shell prompt in IDLE just freezes that I
 cannot enter anything and there is no new  prompt show up. I
 tried ctrl - C and it didn't work. I have to restart IDLE to use it
 again.
 
 My system is Ubuntu Linux 9.04. I used apt-get to install IDLE.

I believe this is the intended behavior.  Look in matplotlib 
documentation on the difference between interactive and non-interactive 
modes.

-- 
--OKB (not okblacke)
Brendan Barnwell
Do not follow where the path may lead.  Go, instead, where there is
no path, and leave a trail.
--author unknown
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to zip a StringIO object?

2009-10-28 Thread Dave Angel

Nagy Viktor wrote:

Hi,

I try to run the following code:

def generate_zip(object_list, template):
result = StringIO.StringIO()
zipped = zipfile.ZipFile(result, w)
for object in object_list:
pdf = generate_pdf(object, template)
if not pdf:
raise IOError(Problem with generating invoice %d %
object.pk)
zipped.writestr(invoice-%d.pdf % object.pk, pdf)
zipped.close()
return result.getvalue()

where generate_pdf returns a valid pdf file's string content, more
precisely it returns a StringIO.getvalue() call containing the pdf
string.

When I add this string to the zip file, I get a problem. Namely, the
zipped files are chmoded to non-readable when extracted. How can I
change this?

thanks,
V

  
You don't tell us the version of Python, nor the OS environment, nor 
what utility you're using to extract these files.


When I supply the missing imports, shortcircuit the missing classes and 
functions, and add some mainline code, I can run this with no problem.  
Are you also running on Windows XP, using 2.6.2, using the same missing 
code as I, and extracting with Winzip 11.2?


DaveA

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


Re: Web development with Python 3.1

2009-10-28 Thread Dotan Cohen
 It
 did not look like I had any control over the tags at all.

 I can tell you you have full control over the whole HTTP response's content
 and headers. And FWIW, this has nothing to do with templating systems.


That's good to know. Actually, it's more that good: I am looking into
Django again.


 Can you provide a code example of printing the variable torvalds in
 the GET request?
 http://example.com/page.py?torvalds=tux
 Should return this:
 htmlbodyptux/p/body/html

 And something similar for a POST request?


 Using which framework ? If it's about Turbogears, I don't use it so I can't
 answer. If it's using Pylons, you can use almost whatever templating system
 you want - or not use any. If it's with Django, do you want it with or
 without the templating system ?


I'd love to see the non-templating Pylons example, and/or the Django
example. Better yet, a link to example code or the appropriate chapter
of TFM would be welcome. So far as I can tell, the fine manual does
not cover non-template output.


 I hate to ask for code, but this conversation would be easier that way.

 Mmmm May I suggest that you first read the relevant documentation for
 the aforementionned frameworks ?


Yes, please! Where in the Django docs is the relevant chapter?


 Ok, here's a Django example without a template:

 # views.py
 def index(request):
   torvalds = request.GET.get(torvalds, No torvalds here)
   return HttpResponse(htmlbody%s/body/html % torvalds)



Allright, but what if I need to output in the middle of the page? Say,
one row of a table that is neither the end nor beginning of the code?
I ask because the construct return makes me believe that this is not
good for this purpose.


 and here's an exemple using a template:

 # templates/index.html

 html
 body
 {{ torvalds }}
 /body
 /html


 # views.py
 def index(request):
   torvalds = request.GET.get(torvalds, No torvalds here)
   return render_to_response(index.html, dict(torvalds=torvalds))


Again, how could I output something in the middle of the page with the
templates?

-- 
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Web development with Python 3.1

2009-10-28 Thread Dotan Cohen
 I've already given you that for TG:

 class RootController(BaseController):

   @expose()
   def page(self, torwalds=None):
       return htmlbodyp%s/p/body/html % (torwalds if torwalds
 else 


Does return mean that this could not be used in the middle of a page?


 Of course nobody would do it that way. Instead, you'd define a template

 html
 xmlns:py='http://genshi.edgewall.org/'bodyp${torvalds}/p/body/html


 And then your code becomes:



   @expose(your.template.path)
   def page(self, torwalds=None):
       return dict(torwalds=torwalds)


 Separation of code from HTML-code. Which most people agree is a good thing.
 And no worries about having to make torwalds a string.


Yes, I like to separate HTML from code. However, often I need to
output something in the middle of the page. How could I do that with a
template?


 Now let's say you want torwalds to be not-empty, and a number:

   @expose(your.template.path)
   @validate(dict(torwalds=Int(not_empty=True)),
 error_handler=some_error_handler_controller_action)
   def page(self, torwalds=None):
       return dict(torwalds=torwalds)


That is nice, I will read more about the error_handler functions. Thanks.


-- 
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il
-- 
http://mail.python.org/mailman/listinfo/python-list


Building Python on Solaris 10?

2009-10-28 Thread Judy Booth
Can anyone point me towards some instructions for building Python on 
Solaris 10?
We need this for some of our test scripts and so far we cannot get this 
to build.

We have tried both Python 2.6.4 and 3.1.1 and both fail with messages 
like this:
Include/pyport.h:685:2: #error LONG_BIT definition appears wrong for 
platform (bad gcc/glibc config?).
*** Error code 1
make: Fatal error: Command failed for target `Modules/python.o'

The configure command used is:
./configure --with-universal-archs=64-bit --enable-universalsdk 
LDFLAGS=-s
-L/usr/local/lib -L/opt/ssl/lib -lgcc --prefix=/opt/python
--prefix=${PREFIX}

and the compiler version is gcc 3.4.3.

A search on Google showed this up as a problem several years ago and 
suggested that there might be a problem with the way configure is working 
on Solaris.

If anyone can help with this that would be great.

Thanks,

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


Re: Web development with Python 3.1

2009-10-28 Thread Dotan Cohen
 Actually, currently in the example url
 http://example.com/path/to/script.py?var1=hellovar2=world the script
 is /home/user/site-name/public_html/path/ (with no filename extension)
 and the script.py is actually page.html which is an arbitrary,
 descriptive string and not part of the script filename.

 Better than the first example wrt/ SEO, but this still ties your url space
 to implementation AFAICT.


Yes, but for the purposes of my needs this is fine and preferable. SEO
was in fact the reason that I started doing this.


 Clearly. I was referring to stdout being send to the browser as the
 http response.

 s/browser/web server/ - it's the web server that reads your app's stdout and
 send it (as is or not FWIW) back to the client.

As is, in my case. Actually, what use case is there for having Apache
reprocess the HTML output of the script?


  And this output to stdout
 thingie is just the ipc scheme used for CGI - there are other possible
 interfaces between the application code and the web server.


Other possible interfaces between the application code and the web
server? Maybe you are referring to the interface with the database
server? Enlighten me, please! I am not a programmer by trade, only by
hobby.


 I think I mentioned that, but I apologize for being
 unclear.

 It's not that it was unclear, but that it's innaccurate. outputting to
 stdout is an implementation detail, and should not be exposed at the
 applicative code level. Dealing with appropriate abstraction - here, an
 HttpResponse object - is far better (well, IMHO of course... - standard
 disclaimers, YMMV etc).


I see. I believe that is called Dotan's Razor: a slight inaccuracy
saves a lengthy explanation.


 Sorry, but all I can replace here are the header and footer - if I want to
 generate a different markup for the content here part, I have to modify
 your applicative code. I've written web apps that way myself (some 7 years
 ago), and still have to maintain some web apps written that way, you know...


Quite so, I though that is what you wanted. Yes, the HTML is
hard-coded into the script. I am learning to abstract and even use
object-oriented approaches, though.


 Does it? I will look into that. I assume that basic support means
 making the cookie, GET and POST variables easily accessible.

 GET and POST at least - I don't exactly remember how it works for cookies.


That much I should be able to google when I get to it.


 I google,
 but cannot find any exapmles of this online.

 Well, no one in it's own mind would still use CGI (except perhaps for very
 trivial stuff) when you have way better solutions.


What I am doing _is_ trivial. However, I thank you for explaining my
options and I will take a second look at them.


 Hey! Since when am I not under attack? :)

 Mmm... yes, I tend to be a bit offensive sometimes - please don't take it
 personnaly and forgive me for my lack of social skills. What I express are
 of course _my_ opinions (most of them based on experience but that's not the
 point), and I've never killed anyone for having a different POV - even if
 I'm pretty sure they are wrong !-)


Be offensive! I take no offence, I understand that your goal is to
help me. I am a hard learner: I recognize that you are teaching me the
better way, but I need convincing as to why it is better. Bruno said
so is good, but saves you coding time down the line is a lot more
convincing!


-- 
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Feedback wanted on programming introduction (Python in Windows)

2009-10-28 Thread Dann Corbit
In article hc8pn3$dd...@news.eternal-september.org, al...@start.no 
says...
 
 [Cross-posted comp.programming and comp.lang.python]
 
 Hi.
 
 I may finally have found the perfect language for a practically oriented 
 introductory book on programming, namely Python.
 
 C++ was way too complex for the novice, JScript and C# suffered from too 
 fast-changing specifications and runtime environment, Java, well, nothing 
 particularly wrong but it's sort of too large and unwieldy and inefficient.
 
 I don't know whether this will ever become an actual book. I hope so!
 
 But since I don't know much Python -- I'm *learning* Python as I write -- I 
 know 
 that there's a significant chance of communicating misconceptions, 
 non-idiomatic 
 ways to do things, bad conventions, etc., in addition to of course plain 
 errors 
 of fact and understanding in general, to which I'm not yet immune...
 
 So I would would be very happy for feedback.
 
 But note: although I'm a complete Python newbie I'm not a novice programmer; 
 my 
 usual programming language is C++. So if you are a novice and think there's 
 something wrong, then please do report it because it may help me explain 
 things 
 better, but since it's likely my explanation that is misleading, don't waste 
 time on building up a case! This also goes for something that is simply 
 difficult to understand. Then reporting that may help me explain it better. 
 On 
 the other hand, if you do have some experience, then chances are that what 
 you 
 think is an error, actually *is* an error! :-)
 
 Unfortunately Google docs doesn't display the nice table of contents in each 
 document, but here's the public view of ch 1 (complete) and ch 2 (about one 
 third completed, I've not yet settled on a title so it's just chapter asd):
 
  http://preview.tinyurl.com/progintro
 
 Cheers,

Why is chapter 2 called ASD?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Feedback wanted on programming introduction (Python in Windows)

2009-10-28 Thread Dann Corbit
In article pan.2009.10.28.07.31...@remove.this.cybersource.com.au, 
ste...@remove.this.cybersource.com.au says...
 
 On Wed, 28 Oct 2009 07:52:17 +0100, Alf P. Steinbach wrote:
 
  Unfortunately Google docs doesn't display the nice table of contents in
  each document, but here's the public view of ch 1 (complete) and ch 2
  (about one third completed, I've not yet settled on a title so it's just
  chapter asd):
  
   http://preview.tinyurl.com/progintro
 
 Unfortunately Google wants me to change my browser, accept a privacy 
 breach (cookies), and open a moderately large security hole in my browser 
 (Javascript). Any one of these on its own, and I wouldn't mind; two of 
 them, and I'd give it some thought; but all three, well, no thank you.
 
 
 I don't suppose you have these chapters available on a public website in 
 an open document format like .odt or similar? Or even better, plain text 
 with markup?

You can read PDF with the ghostscript stuff or the free Adobe stuff.

A man who cannot read .pdf or .ps in today's computer science world is a 
crippled man (IMO-YMMV).

I couldn't live without citeseer, and almost all university computer 
science papers are in either pdf or ps.

I can send you the documents via email if you are unable to collect 
them.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Feedback wanted on programming introduction (Python in Windows)

2009-10-28 Thread Alf P. Steinbach

* Dann Corbit:
In article hc8pn3$dd...@news.eternal-september.org, al...@start.no 


Unfortunately Google docs doesn't display the nice table of contents in each 
document, but here's the public view of ch 1 (complete) and ch 2 (about one 
third completed, I've not yet settled on a title so it's just chapter asd):


 http://preview.tinyurl.com/progintro

Cheers,


Why is chapter 2 called ASD?


The leftmost three keys on the middle row of the keyboard. :-)


Cheers,

- Alf The Ramans do everything in threes
--
http://mail.python.org/mailman/listinfo/python-list


Re: Question on PEP 337 (Vinay Sajip)

2009-10-28 Thread Gabor Urban
Hy guys,

Sorry, Vinay Sajip was right. I wrote my questions about PEP 391. I
would like to know your ideas about my questions posted in my last
mail.

Gabor
-- 
Linux: Choice of a GNU Generation
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Web development with Python 3.1

2009-10-28 Thread Rami Chowdhury
On Wed, 28 Oct 2009 12:42:17 -0700, Dotan Cohen dotanco...@gmail.com  
wrote:



I've already given you that for TG:

class RootController(BaseController):

  @expose()
  def page(self, torwalds=None):
      return htmlbodyp%s/p/body/html % (torwalds if  
torwalds

else 



Does return mean that this could not be used in the middle of a page?


[snip]

Yes, I like to separate HTML from code. However, often I need to
output something in the middle of the page. How could I do that with a
template?



What do you mean by in the middle of the page? Do you mean, for  
instance, the behavior of middle.php in the following PHP example:


?php

include_once(beginning.inc.php);

include_once(middle.php);

include_once(end.inc.php);

?

Is that what you are after?



--
Rami Chowdhury
Never attribute to malice that which can be attributed to stupidity --  
Hanlon's Razor

408-597-7068 (US) / 07875-841-046 (UK) / 0189-245544 (BD)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Hello, world?

2009-10-28 Thread CM
On Oct 28, 5:40 am, Gilles Ganault nos...@nospam.com wrote:
 Hello

 I'm reading O'Reily's Python Programming on Win32, but couldn't find
 a simple example on how to create a window with just a label and
 pushbutton.

 If someone has such a basic example handy, I'm interested.

 Thank you.

In wxPython (which you would have to download and install), it could
be something like:

import wx

class Dialog1(wx.Dialog):
def __init__(self, parent):
wx.Dialog.__init__(self, id=-1, name='', parent=parent,
  pos=wx.Point(132, 174), size=wx.Size(149, 80),
  style=wx.DEFAULT_DIALOG_STYLE, title='')

self.staticText1 = wx.StaticText(id=-1,
  label=u'Hello, World', name='', parent=self,
  pos=wx.Point(40, 16), size=wx.Size(59, 13), style=0)

if __name__ == '__main__':
app = wx.PySimpleApp()
dlg = Dialog1(None)
try:
dlg.ShowModal()
finally:
dlg.Destroy()
app.MainLoop()
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Web development with Python 3.1

2009-10-28 Thread Dotan Cohen
 What do you mean by in the middle of the page? Do you mean, for instance,
 the behavior of middle.php in the following PHP example:

 ?php

 include_once(beginning.inc.php);

 include_once(middle.php);

 include_once(end.inc.php);

 ?

 Is that what you are after?


Yes, that is what I am after. For instance, if one were to look at the
source code of http://dotancohen.com they would see !-- / HEADER
--. All the HTML up to that point was output by bigginin.inc.php.
Similarly, near the end exists div class=bottomfiller, all the
code from there is generated by end.inc.php. These two files are
included in every page of the site.

-- 
Dotan Cohen

http://what-is-what.com
http://gibberish.co.il
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ConfigParser.items sorting

2009-10-28 Thread Dean McClure
On Oct 28, 4:50 pm, Jon Clements jon...@googlemail.com wrote:
 On 28 Oct, 06:21, Dean McClure bratpri...@gmail.com wrote:





  Hi,

  Just wondering how I can get theitems() command fromConfigParserto
  not resort all the item pairs that it presents.

  I am trying to get it to read some data in order:

  [Relay Info]
  relay_name: IPC
  relay_current_range: [60, 64, 68, 72, 76, 80, 84, 88, 92, 96, 100,
  104, 108, 112, 116]
  relay_current_mutliplier: [1/8, 1/4, 1/2, 1, 2, 4]
  relay_i: arcfc/(relay_current_range*relay_current_mutliplier)

  so I can input the data and then eval() the equation at the end but
  when I go
  config.items('Relay Info')
  It mixes everything up, is there a way to stop this?

  Here is my selection code

  variables = sorted(config.items('Relay Info'))
  #Get inputs from user for each variable
  for variable in variables:
          if variable[0] == 'relay_name':
                  vars()[variable[0]] = variable[1]
          else:
                  vars()[variable[0]] = 'not a real thing this is just a fake 
  that
  will never turn up to establish the variable'
                  if variable[1][0] == '[' and variable[1][-1] == ']':
                          if variable[0] != 'Any':
                                  while 
  (variable[1].count(vars()[variable[0]])  1):
                                          vars()[variable[0]] = 
  raw_input(str(variable)[1:-1] + \n)
                                          if 
  variable[1].count(vars()[variable[0]])  1:
                                                  print 'Setting unavailable'
                          else:
                                  vars()[variable[0]] = 
  raw_input(str(variable)[1:-1] + \n)
                  else:
                          vars()[variable[0]] = variable[1]
                  vars()[variable[0]] = float(eval(vars()[variable[0]]))

  Thanks for the help!

 I'm not 100% sure what you're asking, as why should the order be
 important?

 It's probably worth mentioning that the builtin dictionary type is
 'unordered' as it uses hashing to store keys. However, theConfigParsermodule 
 does allow you to supply a dict_type parameter in
 version 2.6+ [http://docs.python.org/library/configparser.html], so
 you could provide an 'ordered dictionary' which returns itsitemsin
 insertion order. There's lots of recipes out there for those, but I
 believe Raymond Hettinger has a fairly good one on the ActiveState(?)
 cookbook site. (Google for python cookbook).

 Since however, the idea of processing INI files is that you *know*
 what you're looking for and how to interpret it, I'm not sure why
 you're not using something similar to this (v2.6.2):

 relay_name = config.get('Relay Info', 'relay_name')
 relay_current_range = config.get('Relay Info', 'relay_current_range')
 relay_current_range_list = eval(relay_current_range)

 ...etc...

 hth,

 Jon.

Sorry, basically I was just using configparser to pull sets of
variables and equations to calculate the clearing time of a circuit
breaker. As each device is slightly different and I like the structure
of the configparser I decided it'd be an acceptable way to do this.
The thing is that I wanted to have the relay settings in the first
section, then have sections for different protection settings, all of
these have a few input parameters and an output for clearing time. The
user will select the config file for the relay they want and therefore
not all the settings will be the same, I know this isn't the intended
use of the configparser but I thought it'd be much easier for people
to run from their hdd, just a folder of conf files that can be edited
or expanded on with relative ease.

In order to accommodate for all the different configurations I thought
I would have (as my code was showing but poorly explained) the
variable name in the config file (these will be standardised to a
degree) set to be either a set value or a selectable range in which
the program will ask the user to select a value from the range. One
relay may have a value for overload that is a percentage of the CT
value while others may have a selected full load current which is used
for everything so having all the input variables and then the equation
to output the clearing time means that I can ask for the input values
and evaluate the equation. Or at least I would be able to if I could
output them in order?

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


Re: IDLE python shell freezes after running show() of matplotlib

2009-10-28 Thread Chris Colbert
This is a threading issue that is very common when using gui toolkits
with the interactive interpreter.

You're better off just using ipython, which already has builtin
support for matplotlib when you start it via ipython -pylab



On Wed, Oct 28, 2009 at 7:41 PM, OKB (not okblacke)
brennospamb...@nobrenspambarn.net wrote:
 Forrest Sheng Bao wrote:

 I am having a weird problem on IDLE. After I plot something using show
 () of matplotlib, the python shell prompt in IDLE just freezes that I
 cannot enter anything and there is no new  prompt show up. I
 tried ctrl - C and it didn't work. I have to restart IDLE to use it
 again.

 My system is Ubuntu Linux 9.04. I used apt-get to install IDLE.

        I believe this is the intended behavior.  Look in matplotlib
 documentation on the difference between interactive and non-interactive
 modes.

 --
 --OKB (not okblacke)
 Brendan Barnwell
 Do not follow where the path may lead.  Go, instead, where there is
 no path, and leave a trail.
        --author unknown
 --
 http://mail.python.org/mailman/listinfo/python-list

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


Re: calling server side function

2009-10-28 Thread Chris Colbert
I second the suggestion for XML-RPC...

It also solves the security issue in your example, by only exporting
functions you specifically register...

look at xmlrpclib in the standard python library.

On Wed, Oct 28, 2009 at 8:59 AM, Gabriel Genellina
gagsl-...@yahoo.com.ar wrote:
 En Wed, 28 Oct 2009 04:04:50 -0300, Paul Hartley luapyelt...@hotmail.com
 escribió:

 I have a socket set up between a client and server program.  Let's say
 that I serialize (pickle) some data in the client and send it to the server
 with the intention of calling a function in the server to process the data.
  How would one execute the function?  This is not for a web-based
 application, BTW -- it's a desktop based application
 My current thought process is (using a generalized example):
 I have a list of numbers in the client and want to find the length of the
 list using the server.  There exists a function find_len() in the server
 code.  I have a list of numbers [1,2,3].  On the client side, I create the
 tuple (find_len, [1,2,3]), and serialize it.  I pass this serialized
 object via a socket to the server, which unpickles it.  The server takes the
 key (find_len) and uses a getattr call to get the find_len function.  The
 server then calls find_len([1,2,3]) to get the sum.
 def find_len(list_):    return
 Are there better ways of accomplishing this (I'm aware that there are
 security pitfalls here...)

 xmlrpc does more or less the same thing, but serializing in xml instead of
 pickling.

 --
 Gabriel Genellina

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

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


Re: PEP 391 (Dictionary-Based Configuration for Logging) Updated

2009-10-28 Thread Vinay Sajip
Wolodja Wentland wentland at cl.uni-heidelberg.de writes:

  All feedback gratefully received!
 
 The PEP does not seem to specify how handler are retrieved by their
 name/id. How should this work? Especially given the statement:
 
 The handler name lookup dictionary is for configuration use only
  and will not become part of the public API for the package.
 

What I mean by this is that, if you specify some handlers in the initial
configuration:

handlers:
  console:
# configuration for a handler
  file:
# configuration for a handler
  email:
# configuration for a handler

then internally, there will be a map which has keys console, file and
email pointing to the respective handlers. In a later incremental call,
you can do

handlers:
  console:
level = ...
  file:
level = ...
  email:
level = ...

and the levels will be set on the handlers previously set up with the same
ids.

If you set up handlers programmatically and give them names:

h = logging.StreamHandler()

h.name = console

this will add an entry to the map with key console and a reference to h as
the value.

Regards,

Vinay Sajip

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


Bug(s) in Python 3.1.1 Windows installation

2009-10-28 Thread Alf P. Steinbach

Hi.

Or, to whomever this concerns... ;-)


I thought it would be prudent to install 3.1.1 for Windows from scratch, so I 
uninstalled everything (CPython, ActivePython), and then installed Python 3.1.1.


In the Advanced option I told the installer to compile packages.

The compiler then found a few syntax errors apparently in some text conversion 
test programs, and finally a message box popped up saying that There is a 
problem with this Windows Installer Package,


http://imgur.com/N6Pbp

and the main installation dialog then reported Python 3.1.1 installer ended 
prematurely. [...] Your system has not been modified.


http://imgur.com/0kzMS.png

OK, I'll try again /without/ asking it to compile. I'm just reporting this so 
that whoever needs to know knows (including maintainers and people wanting to 
install this).



Cheers,

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


Re: Question on PEP 337

2009-10-28 Thread Vinay Sajip
Gabor Urban urbangabo at gmail.com writes:

 
 Hy guys,
 
 this PEP is very well written, and I have found the discussion inspiring.
 
 Every time I use the logging module, I have the configuration hardcoded in
 the application. That is why I never used the configuration file based
 approach. Now I will give it a try.
 
 I think we should discuss the following scenario (it was not clear in the
 PEP for me) : an application has the logging configuration in a config file
 and it is  currently running. The user edits this file, so the configuiration
 in the running process should be changed.

You would have to do this by hand: watch for file changes, reload the file
into a dict, call logging.config.dictConfig with the new dict.

PEP 391 is basically about using a dict to configure logging, but doesn't say
where the dict comes from - it could be from deserializing a YAML or JSON file
or importing a Python source file, or it could be received as a pickle over the
wire and unpickled ... the logging package only knows about the dict and this
must follow the schema described in the PEP.

Regards,

Vinay Sajip


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


Re: Bug(s) in Python 3.1.1 Windows installation

2009-10-28 Thread Alf P. Steinbach

* Alf P. Steinbach:

Hi.

Or, to whomever this concerns... ;-)


I thought it would be prudent to install 3.1.1 for Windows from scratch, 
so I uninstalled everything (CPython, ActivePython), and then installed 
Python 3.1.1.


In the Advanced option I told the installer to compile packages.

The compiler then found a few syntax errors apparently in some text 
conversion test programs, and finally a message box popped up saying 
that There is a problem with this Windows Installer Package,


http://imgur.com/N6Pbp

and the main installation dialog then reported Python 3.1.1 installer 
ended prematurely. [...] Your system has not been modified.


http://imgur.com/0kzMS.png

OK, I'll try again /without/ asking it to compile. I'm just reporting 
this so that whoever needs to know knows (including maintainers and 
people wanting to install this).


Hm, the installer forgot to clean up, leaving lots of files, so contrary to the 
dialog's final message the system had been modified.


Cheers,

- Alf (now going to try this again without asking it to compile)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Web development with Python 3.1

2009-10-28 Thread Albert Hopkins
On Wed, 2009-10-28 at 15:32 +0200, Dotan Cohen wrote:
  def index(request):
 unmaintanable_html = 
  html
   head
 titleIndex/title
   /head
   body
 h1Embedded HTML is a PITA/h1
 pbut some like pains.../p
   /body
  /html
  
 return HttpResponse(unmaintanable_html)
 
 
 And if I need to add a variable or three in there? Static HTML I can
 do without Python.
 

Put the variables in  a dict and then return

unmaintanable_html % varDict

Or, if you want the the static HTML in a file then you can return

open(static_html_filename).read() % varDict

Add any complexity beyond that though and you're pretty much on your way
to writing a template engine ;-)

-a


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


Re: Web development with Python 3.1

2009-10-28 Thread Rami Chowdhury
On Wed, 28 Oct 2009 14:15:54 -0700, Dotan Cohen dotanco...@gmail.com  
wrote:


What do you mean by in the middle of the page? Do you mean, for  
instance,

the behavior of middle.php in the following PHP example:

?php

include_once(beginning.inc.php);

include_once(middle.php);

include_once(end.inc.php);

?

Is that what you are after?



Yes, that is what I am after. For instance, if one were to look at the
source code of http://dotancohen.com they would see !-- / HEADER
--. All the HTML up to that point was output by bigginin.inc.php.
Similarly, near the end exists div class=bottomfiller, all the
code from there is generated by end.inc.php. These two files are
included in every page of the site.



I think you're misunderstanding how Python and the web work together.  
Python is not PHP -- it was not designed to replace HTML, and it is in  
itself not a templating language. If you would like to use Python code  
embedded in HTML, the way PHP is typically used, you may want to look at  
Python Server Pages  
(http://www.modpython.org/live/current/doc-html/pyapi-psp.html) which are  
provided by mod_python.


Just so you know (as I think this is what is causing much of the  
misunderstanding here), most Python web frameworks *do not* subscribe to  
the traditional model of the web, where URLs represent files on a server.  
(In the case of PHP, Python Server Pages, or CGI scripts, these are  
augmented files which are executed by the server, but it's the same  
concept). Instead, they typically map URLs to arbitrary code.


--
Rami Chowdhury
Never attribute to malice that which can be attributed to stupidity --  
Hanlon's Razor

408-597-7068 (US) / 07875-841-046 (UK) / 0189-245544 (BD)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Web development with Python 3.1

2009-10-28 Thread Albert Hopkins
On Wed, 2009-10-28 at 16:38 +0200, Dotan Cohen wrote:
  return HttpResponse(unmaintanable_html % data)
 
 
 That's fine for single variables, but if I need to output a table of
 unknown rows?  I assume that return means the end of the script.
 Therefore I should shove the whole table into a variable and then copy
 that variable to the array data?
 
No, if you use a templating system like Django's then basically you pass
a QuerySet to your template.  A QuerySet is basically a pointer to a SQL
query, for example.  The templating system just knows to expect an
iterable, it can be a list of rows or it can be a QuerySet which does a
fetch from a database.  No need to shove an entire table into a
variable.
 
  - second solution: do basically the same thing with a template
 system -
  which will give you much more power and options...
 
 
 I will look further into the Django templates, I promise. But I would
 still like to know how to work with Python proper.

Another advantage if templates for many is that it allows programmers to
do what they do best (write code) while letting web designers do what
they do best (designing web pages) without them walking over each other
(that much).

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


Re: ftpilb.FTP.stor...() freeze mystery

2009-10-28 Thread Gabriel Genellina
En Wed, 28 Oct 2009 08:05:22 -0300, Anthra Norell  
anthra.nor...@bluewin.ch escribió:

Gabriel Genellina wrote:

En Tue, 27 Oct 2009 07:53:36 -0300, Anthra Norell
anthra.nor...@bluewin.ch escribió:

I am trying to upload a bunch of web pages to a hosting service.[...]   
I wrote a loop that iterates through the file names and calls either  
of the stor... () methods as appropriate. The loop successfully  
uploads eight of some twenty files and then freezes. Ctrl-C doesn't  
unlock the freeze. I have to kill the IDLE window


freezes are less predictable than it seemed in the beginning. On one  
occasion it occurred after the transfer of a single file from the IDLE  
command line (my_ftp_object.storlines (STOR file_name, f). The file  
did upload. So the freezes seem to occur after a successful transfer.


In this thread from last month, Sean DiZazzo shows how to add a timeout  
parameter to storbinary:

http://comments.gmane.org/gmane.comp.python.general/639258
Do the same with storlines and see whether it helps.

--
Gabriel Genellina

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


Working threads progress

2009-10-28 Thread mattia
hi all, I have a simple program that uses multiple threads to carry out 
some work. Every threads share the same queue.Queue() (that is 
synchronized) in order to get some data and then carry out the work. 
Suppose I have something like:
q = queue.Queue()
for x in range(100):
q.put(x)
then I have:
lock = threading.Lock()
d = {}
threads = [Thread(target=do_work, args=(q, lock, d)) for _ in range(5)]
every thread thakes an item in the queue (using .get()) and compute some 
expensive work. Then updates the dictionary using the queue item as a key 
and the result obtained as the value (using the lock before and after the 
dict update).
Now, I would like to know the activity done (e.g. every two seconds) so I 
create another thread that checks the queue size (using .qsize()). Have 
you any suggestion to improve the code?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ConfigParser.items sorting

2009-10-28 Thread Jon Clements
On 28 Oct, 21:55, Dean McClure bratpri...@gmail.com wrote:
 On Oct 28, 4:50 pm, Jon Clements jon...@googlemail.com wrote:



  On 28 Oct, 06:21, Dean McClure bratpri...@gmail.com wrote:

   Hi,

   Just wondering how I can get theitems() command fromConfigParserto
   not resort all the item pairs that it presents.

   I am trying to get it to read some data in order:

   [Relay Info]
   relay_name: IPC
   relay_current_range: [60, 64, 68, 72, 76, 80, 84, 88, 92, 96, 100,
   104, 108, 112, 116]
   relay_current_mutliplier: [1/8, 1/4, 1/2, 1, 2, 4]
   relay_i: arcfc/(relay_current_range*relay_current_mutliplier)

   so I can input the data and then eval() the equation at the end but
   when I go
   config.items('Relay Info')
   It mixes everything up, is there a way to stop this?

   Here is my selection code

   variables = sorted(config.items('Relay Info'))
   #Get inputs from user for each variable
   for variable in variables:
           if variable[0] == 'relay_name':
                   vars()[variable[0]] = variable[1]
           else:
                   vars()[variable[0]] = 'not a real thing this is just a 
   fake that
   will never turn up to establish the variable'
                   if variable[1][0] == '[' and variable[1][-1] == ']':
                           if variable[0] != 'Any':
                                   while 
   (variable[1].count(vars()[variable[0]])  1):
                                           vars()[variable[0]] = 
   raw_input(str(variable)[1:-1] + \n)
                                           if 
   variable[1].count(vars()[variable[0]])  1:
                                                   print 'Setting 
   unavailable'
                           else:
                                   vars()[variable[0]] = 
   raw_input(str(variable)[1:-1] + \n)
                   else:
                           vars()[variable[0]] = variable[1]
                   vars()[variable[0]] = float(eval(vars()[variable[0]]))

   Thanks for the help!

  I'm not 100% sure what you're asking, as why should the order be
  important?

  It's probably worth mentioning that the builtin dictionary type is
  'unordered' as it uses hashing to store keys. However, 
  theConfigParsermodule does allow you to supply a dict_type parameter in
  version 2.6+ [http://docs.python.org/library/configparser.html], so
  you could provide an 'ordered dictionary' which returns itsitemsin
  insertion order. There's lots of recipes out there for those, but I
  believe Raymond Hettinger has a fairly good one on the ActiveState(?)
  cookbook site. (Google for python cookbook).

  Since however, the idea of processing INI files is that you *know*
  what you're looking for and how to interpret it, I'm not sure why
  you're not using something similar to this (v2.6.2):

  relay_name = config.get('Relay Info', 'relay_name')
  relay_current_range = config.get('Relay Info', 'relay_current_range')
  relay_current_range_list = eval(relay_current_range)

  ...etc...

  hth,

  Jon.

 Sorry, basically I was just using configparser to pull sets of
 variables and equations to calculate the clearing time of a circuit
 breaker. As each device is slightly different and I like the structure
 of the configparser I decided it'd be an acceptable way to do this.
 The thing is that I wanted to have the relay settings in the first
 section, then have sections for different protection settings, all of
 these have a few input parameters and an output for clearing time. The
 user will select the config file for the relay they want and therefore
 not all the settings will be the same, I know this isn't the intended
 use of the configparser but I thought it'd be much easier for people
 to run from their hdd, just a folder of conf files that can be edited
 or expanded on with relative ease.

 In order to accommodate for all the different configurations I thought
 I would have (as my code was showing but poorly explained) the
 variable name in the config file (these will be standardised to a
 degree) set to be either a set value or a selectable range in which
 the program will ask the user to select a value from the range. One
 relay may have a value for overload that is a percentage of the CT
 value while others may have a selected full load current which is used
 for everything so having all the input variables and then the equation
 to output the clearing time means that I can ask for the input values
 and evaluate the equation. Or at least I would be able to if I could
 output them in order?


As Steven has already said, you're lone to an injection attack, don't
allow it.

What language do you orig. come from? ie, what would you say is your
'strongest' language.

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


Re: popen function of os and subprocess modules

2009-10-28 Thread Albert Hopkins
On Wed, 2009-10-28 at 07:15 -0700, banu wrote:
 
 Thanks for the reply Jon
 Basically I need to move into a folder and then need to execute some
 shell commands(make etc.) in that folder. I just gave 'ls' for the
 sake of an example. The real problem I am facing is, how to stay in
 the folder after popen('cd directory') finishes. It seems trivial, but
 I am not able to do it. 

The problem is that you are running 2 child, and it's the first
subprocess that's changing the directory and then exiting.  This
actually has little to do with Python specifically.  you can  see the
same thing if you do this:

$ pwd
/tmp
$ cat mycd.sh 
#!/bin/sh

cd /etc
$ ./mycd.sh 
$ pwd
/tmp

As you can see I am still in tmp.  This is because mycd.sh changed
to /etc/ but after it exits back to the parent process it is back
in /tmp.

What you want is to cd inside your script itself.  os.chdir() does
this.



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


Re: ConfigParser.items sorting

2009-10-28 Thread Dean McClure
On Oct 29, 9:05 am, Jon Clements jon...@googlemail.com wrote:
 On 28 Oct, 21:55, Dean McClure bratpri...@gmail.com wrote:





  On Oct 28, 4:50 pm, Jon Clements jon...@googlemail.com wrote:

   On 28 Oct, 06:21, Dean McClure bratpri...@gmail.com wrote:

Hi,

Just wondering how I can get theitems() command fromConfigParserto
not resort all the item pairs that it presents.

I am trying to get it to read some data in order:

[Relay Info]
relay_name: IPC
relay_current_range: [60, 64, 68, 72, 76, 80, 84, 88, 92, 96, 100,
104, 108, 112, 116]
relay_current_mutliplier: [1/8, 1/4, 1/2, 1, 2, 4]
relay_i: arcfc/(relay_current_range*relay_current_mutliplier)

so I can input the data and then eval() the equation at the end but
when I go
config.items('Relay Info')
It mixes everything up, is there a way to stop this?

Here is my selection code

variables = sorted(config.items('Relay Info'))
#Get inputs from user for each variable
for variable in variables:
        if variable[0] == 'relay_name':
                vars()[variable[0]] = variable[1]
        else:
                vars()[variable[0]] = 'not a real thing this is just a 
fake that
will never turn up to establish the variable'
                if variable[1][0] == '[' and variable[1][-1] == ']':
                        if variable[0] != 'Any':
                                while 
(variable[1].count(vars()[variable[0]])  1):
                                        vars()[variable[0]] = 
raw_input(str(variable)[1:-1] + \n)
                                        if 
variable[1].count(vars()[variable[0]])  1:
                                                print 'Setting 
unavailable'
                        else:
                                vars()[variable[0]] = 
raw_input(str(variable)[1:-1] + \n)
                else:
                        vars()[variable[0]] = variable[1]
                vars()[variable[0]] = float(eval(vars()[variable[0]]))

Thanks for the help!

   I'm not 100% sure what you're asking, as why should the order be
   important?

   It's probably worth mentioning that the builtin dictionary type is
   'unordered' as it uses hashing to store keys. However, 
   theConfigParsermodule does allow you to supply a dict_type parameter in
   version 2.6+ [http://docs.python.org/library/configparser.html], so
   you could provide an 'ordered dictionary' which returns itsitemsin
   insertion order. There's lots of recipes out there for those, but I
   believe Raymond Hettinger has a fairly good one on the ActiveState(?)
   cookbook site. (Google for python cookbook).

   Since however, the idea of processing INI files is that you *know*
   what you're looking for and how to interpret it, I'm not sure why
   you're not using something similar to this (v2.6.2):

   relay_name = config.get('Relay Info', 'relay_name')
   relay_current_range = config.get('Relay Info', 'relay_current_range')
   relay_current_range_list = eval(relay_current_range)

   ...etc...

   hth,

   Jon.

  Sorry, basically I was just usingconfigparserto pull sets of
  variables and equations to calculate the clearing time of a circuit
  breaker. As each device is slightly different and I like the structure
  of theconfigparserI decided it'd be an acceptable way to do this.
  The thing is that I wanted to have the relay settings in the first
  section, then have sections for different protection settings, all of
  these have a few input parameters and an output for clearing time. The
  user will select the config file for the relay they want and therefore
  not all the settings will be the same, I know this isn't the intended
  use of theconfigparserbut I thought it'd be much easier for people
  to run from their hdd, just a folder of conf files that can be edited
  or expanded on with relative ease.

  In order to accommodate for all the different configurations I thought
  I would have (as my code was showing but poorly explained) the
  variable name in the config file (these will be standardised to a
  degree) set to be either a set value or a selectable range in which
  the program will ask the user to select a value from the range. One
  relay may have a value for overload that is a percentage of the CT
  value while others may have a selected full load current which is used
  for everything so having all the input variables and then the equation
  to output the clearing time means that I can ask for the input values
  and evaluate the equation. Or at least I would be able to if I could
  output them in order?

 As Steven has already said, you're lone to an injection attack, don't
 allow it.

 What language do you orig. come from? ie, what would you say is your
 'strongest' language.

 Jon.

Probably C, I'm not used to having so many functions :( I have a
terrible tendency to build from the bottom and then stumble 

Re: Bug(s) in Python 3.1.1 Windows installation

2009-10-28 Thread Gabriel Genellina
En Wed, 28 Oct 2009 19:18:48 -0300, Alf P. Steinbach al...@start.no  
escribió:


I thought it would be prudent to install 3.1.1 for Windows from scratch,  
so I uninstalled everything (CPython, ActivePython), and then installed  
Python 3.1.1.

In the Advanced option I told the installer to compile packages.
The compiler then found a few syntax errors apparently in some text  
conversion test programs, and finally a message box popped up saying  
that There is a problem with this Windows Installer Package,


Did you install it over an existing directory, that might contain modules  
intended for a previous version, e.g. c:\python?


Even if you uninstall Python, the uninstaller removes *only* the files  
*it* copied; everything else is left alone. This includes  
modules/libraries/packages that you may have installed in the past.  
Libraries written for any 2.x version are not compatible with the new 3.x  
syntax; if any of those libraries exist in the directory where you install  
3.1.1, you get an error like yours.


OK, I'll try again /without/ asking it to compile. I'm just reporting  
this so that whoever needs to know knows (including maintainers and  
people wanting to install this).


The best place to report bugs is http://bugs.python.org/

--
Gabriel Genellina

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


Re: Bug(s) in Python 3.1.1 Windows installation

2009-10-28 Thread Gabriel Genellina
En Wed, 28 Oct 2009 19:30:13 -0300, Alf P. Steinbach al...@start.no  
escribió:


Hm, the installer forgot to clean up, leaving lots of files, so contrary  
to the dialog's final message the system had been modified.


If those files are third-party libraries, this confirms my previous post.  
It's not the 3.1.1 installer that forgot to clean up, but files from a  
previous 2.x installation.


--
Gabriel Genellina

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


Re: Feedback wanted on programming introduction (Python in Windows)

2009-10-28 Thread Gabriel Genellina
En Wed, 28 Oct 2009 08:49:02 -0300, Alf P. Steinbach al...@start.no  
escribió:


I suggested ActiveState because I know from earlier that their packages  
are easy to install and provide documentation in reasonable Windows CHM  
help file format. I did try the IronPython .NET implementation first  
:-). But my experience with *nix folks' porting efforts is that they  
create Windows ports that don't handle spaces in paths, don't even  
handle backspace in dialogs they present, require undocumented  
environment variables set up (and explaining such takes a lot of pages   
is demotivating), and just generally without any forethought or any  
reasonable automation, requiring a lot of explanation and hand-holding  
which would run to many pages, so I didn't even look at the CPython  
implementation.


Perhaps I should.


Certainly. The ActiveState folks do a great work, but currently most of  
the features listed for ActivePython on Windows are standard in the  
python.org distribution. Like .chm help files, all core extensions  
(zlib, bz2, sqlite...), all additional documentation (FAQ, What's new,  
PEPs, everything except the dive into python book). The biggest thing  
not included in the python.org distribution is the pywin32 package and  
related stuff (like the PythonWin editor).
Maybe in the past the gap between both distributions were larger, but now,  
the official Python build is perfecty suitable for Windows users.


--
Gabriel Genellina

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


Re: Web development with Python 3.1

2009-10-28 Thread Rhodri James

On Wed, 28 Oct 2009 07:08:12 -, John Nagle na...@animats.com wrote:


Alan Harris-Reid wrote:

I am very much new to Python, and one of my first projects is a simple
data-based website. I am starting with Python 3.1


Until MySQLdb gets ported to something later than Python 2.5, support
for a data-based web site probably has to be in Python 2.5 or earlier.


Aside from the deprecation warning, MySQLdb appears to work perfectly well
on my Ubuntu Python 2.6.  Since my spare-time teach-myself activity has  
been

playing with it, I'd have expected to notice lack of support by now.

--
Rhodri James *-* Wildebeest Herder to the Masses
--
http://mail.python.org/mailman/listinfo/python-list


Re: Bug(s) in Python 3.1.1 Windows installation

2009-10-28 Thread Alf P. Steinbach

* Alf P. Steinbach:

* Alf P. Steinbach:

Hi.

Or, to whomever this concerns... ;-)


I thought it would be prudent to install 3.1.1 for Windows from 
scratch, so I uninstalled everything (CPython, ActivePython), and then 
installed Python 3.1.1.


In the Advanced option I told the installer to compile packages.

The compiler then found a few syntax errors apparently in some text 
conversion test programs, and finally a message box popped up saying 
that There is a problem with this Windows Installer Package,


http://imgur.com/N6Pbp

and the main installation dialog then reported Python 3.1.1 installer 
ended prematurely. [...] Your system has not been modified.


http://imgur.com/0kzMS.png

OK, I'll try again /without/ asking it to compile. I'm just reporting 
this so that whoever needs to know knows (including maintainers and 
people wanting to install this).


Hm, the installer forgot to clean up, leaving lots of files, so contrary 
to the dialog's final message the system had been modified.


OK, after failing the Python 3.1.1 installer did manage to leave an uninstaller 
for itself, and I ran that.



(1) Sluggish installer (about 600x slower than necessary)

What should be a simple removal of files and registry keys taking all of 1.5 
seconds or so took about 10 minutes. I've experienced this before with 
Microsoft's installer technology (MSI). Apparently it utilizes the infamuous 
Microsoft never use an O(n) algorithm where an O(n^2) or O(n^3) algorithm will 
do on a sufficiently fast machine strategy.


So I suggest switching to some other more light-weight installer technology.


(2) Failure to set up PATH.

Without asking the Python 3.1.1 installer to compile packages it now installed, 
but it failed to set up the PATH environment variable (the ActivePython 
installation also failed to do that, but I worked around it in my writings by 
just not using the python command yet, referring to that in a footnote).


The installer did manage to do the rest of that part correctly: file 
associations and PATHEXT variable.


In new command interpreter instance:


example of=what the Python 3.1.1 installer did manage to do correctly
C:\Documents and Settings\Alf echo %pathext%
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.CJS;.JS;.JSE;.WSF;.WSH;.RB;.RBW;.tcl;.py;.pyw

C:\Documents and Settings\Alf assoc | find /i pyt
.py=Python.File
.pyc=Python.CompiledFile
.pyo=Python.CompiledFile
.pyw=Python.NoConFile

C:\Documents and Settings\Alf ftype | find /i pyt
Python.CompiledFile=C:\Program Files\cpython\python31\python.exe %1 %*
Python.File=C:\Program Files\cpython\python31\python.exe %1 %*
Python.NoConFile=C:\Program Files\cpython\python31\pythonw.exe %1 %*
/example


(3) Tkinter not bundled, misleading  incomplete documentation.

With the file associations in place (the installer managed to do that) running 
console programs works fine.


However, running Tkinter based programs does *not* work:


code filename=ellipse.pyw
import Tkinter

window = Tkinter.Tk()
window.title( A fixed size ellipse... )
window.geometry( 350x200 )# Client area size, not window size.
window.resizable( width = 0, height = 0 )

canvas = Tkinter.Canvas( window, bg = white )
bbox = 2, 2, 347, 197   # Pixel coors left, top, right, bottom
canvas.create_oval( *bbox, fill = PeachPuff )
canvas.pack()   # Fill the entire client area, please.

window.mainloop()   # Process events until window is closed.
/code


example of=Tkinter does not work after installation
C:\Documents and Settings\Alf python ellipse.pyw
'python' is not recognized as an internal or external command,
operable program or batch file.

C:\Documents and Settings\Alf C:\Program Files\cpython\python31\python.exe 
ellipse.pyw

Traceback (most recent call last):
  File ellipse.pyw, line 1, in module
import Tkinter
ImportError: No module named Tkinter
/example


Even after setting up a correct PATH Tkinter does not work:


example of=Tkinter doesn't work even with correct PATH
C:\Documents and Settings\Alf set path=%path%;C:\Program Files\cpython\python31

C:\Documents and Settings\Alf python ellipse.pyw
Traceback (most recent call last):
  File ellipse.pyw, line 1, in module
import Tkinter
ImportError: No module named Tkinter
/example



Checking I find that while there is a Tkinter folder there is no file 
[Tkinter.py] in this installation, i.e. the Tkinter module is not bundled with 
this distribution.


That's bad news for any novice wanting to start learning the language: a main 
battery is missing! The documentation gives the impression that Tkinter can 
just be used, and it could just be used with ActivePython. Here the novice has 
to figure out not only that it isn't there, but also how to get it!


Checking url: http://pypi.python.org/pypi/, the package index, nope, no 
Tkinter there.


Typing tkinter in the Firefox address bar leads to url: 
http://wiki.python.org/moin/TkInter, and it has a recipe 

Re: Bug(s) in Python 3.1.1 Windows installation

2009-10-28 Thread Alf P. Steinbach

* Gabriel Genellina:
En Wed, 28 Oct 2009 19:30:13 -0300, Alf P. Steinbach al...@start.no 
escribió:


Hm, the installer forgot to clean up, leaving lots of files, so 
contrary to the dialog's final message the system had been modified.


If those files are third-party libraries, this confirms my previous 
post. It's not the 3.1.1 installer that forgot to clean up, but files 
from a previous 2.x installation.


No, those files were the 3.1 installation directory + subdirectories and files.


Cheers  hth.,

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


Re: Bug(s) in Python 3.1.1 Windows installation

2009-10-28 Thread Alf P. Steinbach

* Gabriel Genellina:
En Wed, 28 Oct 2009 19:18:48 -0300, Alf P. Steinbach al...@start.no 
escribió:


I thought it would be prudent to install 3.1.1 for Windows from 
scratch, so I uninstalled everything (CPython, ActivePython), and then 
installed Python 3.1.1.

In the Advanced option I told the installer to compile packages.
The compiler then found a few syntax errors apparently in some text 
conversion test programs, and finally a message box popped up saying 
that There is a problem with this Windows Installer Package,


Did you install it over an existing directory, that might contain 
modules intended for a previous version, e.g. c:\python?


No, completely clean install.


Even if you uninstall Python, the uninstaller removes *only* the files 
*it* copied; everything else is left alone. This includes 
modules/libraries/packages that you may have installed in the past. 
Libraries written for any 2.x version are not compatible with the new 
3.x syntax; if any of those libraries exist in the directory where you 
install 3.1.1, you get an error like yours.


No, after uninstalling previous stuff I manually cleaned up remains (to the 
point of removing left over file extensions in PATHEXT).



OK, I'll try again /without/ asking it to compile. I'm just reporting 
this so that whoever needs to know knows (including maintainers and 
people wanting to install this).


The best place to report bugs is http://bugs.python.org/


Sure, thanks.

But there are three reasons why I posted here. (1) I'm lazy. (2) It can help 
others. (3) Faster response times, including helpful responses like yours (and 
yes it would really have been helpful if that was the problem, so thanks! :-) )



Cheers,

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


Re: Bug(s) in Python 3.1.1 Windows installation

2009-10-28 Thread Mark Hammond

On 29/10/2009 11:06 AM, Alf P. Steinbach wrote:


So I suggest switching to some other more light-weight installer
technology.


Thanks for the suggestion, but I expect we will stick with MSI even with 
its shortcomings.  Using MSI files has significant other advantages, 
particularly in managed environments.



(2) Failure to set up PATH.


This is by design.  If you really care passionately about this, you 
should be able to find a number of discussions here, in python-dev and 
in the python bug tracker.


One example of why the current behaviour is useful is that many people 
install multiple Python versions side-by-side and a last installed 
wins strategy isn't a great option.



Even after setting up a correct PATH Tkinter does not work:


I suspect this will be a Python 3.x issue - you probably want to stick 
with 2.x.


HTH,

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


Re: Copying a ZipExtFile

2009-10-28 Thread ryles
On Oct 23, 1:15 pm, Moore, Mathew L moor...@battelle.org wrote:
 Hello all,

 A newbie here.  I was wondering why the following fails on Python 2.6.2 
 (r262:71605) on win32.  Am I doing something inappropriate?

 Interestingly, it works in 3.1, but would like to also get it working in 2.6.

 Thanks in advance,
 --Matt

 import io
 import shutil
 import tempfile
 import zipfile

 with tempfile.TemporaryFile() as f:
     # (Real code retrieves archive via urllib2.urlopen().)
     zip = zipfile.ZipFile(f, mode='w')
     zip.writestr('unknowndir/src.txt', 'Hello, world!')
     zip.close();

     # (Pretend we just downloaded the zip file.)
     f.seek(0)

     # Result of urlopen() is not seekable, but ZipFile requires a
     # seekable file.  Work around this by copying the file into a
     # memory stream.
     with io.BytesIO() as memio:
         shutil.copyfileobj(f, memio)
         zip = zipfile.ZipFile(file=memio)
         # Can't use zip.extract(), because I want to ignore paths
         # within archive.
         src = zip.open('unknowndir/src.txt')
         with open('dst.txt', mode='wb') as dst:
             shutil.copyfileobj(src, dst)

 The last line throws an Error:

 Traceback (most recent call last):
   File test.py, line 25, in module
     shutil.copyfileobj(src, dst)
   File C:\Python26\lib\shutil.py, line 27, in copyfileobj
     buf = fsrc.read(length)
   File C:\Python26\lib\zipfile.py, line 594, in read
     bytes = self.fileobj.read(bytesToRead)
 TypeError: integer argument expected, got 'long'

It should hopefully work if you use cStringIO/StringIO instead of
BytesIO.

I think the issue is essentially that StringIO.read() will accept a
long object while the backport of bytesio to to 2.6 does an explicit
check for int:

py StringIO.StringIO(foo).read(long(1))
'f'

py io.BytesIO(foo).read(long(1))
Traceback (most recent call last):
  File stdin, line 1, in module
TypeError: integer argument expected, got 'long'

Should this be amended? Perhaps someone on core can consider it.

As for why the bytesToRead calculation in ZipExtFile.read() results in
a long, I've not yet looked at it closely.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Re: Web development with Python 3.1

2009-10-28 Thread Alan Harris-Reid

John Nagle wrote:

div class=moz-text-flowedAlan Harris-Reid wrote:

I am very much new to Python, and one of my first projects is a simple
data-based website. I am starting with Python 3.1 


   Until MySQLdb gets ported to something later than Python 2.5, support
for a data-based web site probably has to be in Python 2.5 or earlier.

   The C module situation for Python 3.x still isn't very good.
Realistically, the production version of Python is 2.5.  This process
is taking long enough that I'm worried that Python 3.x could do for
Python what Perl 6 did for Perl - provide an upgrade path that nobody
takes.

   HTMLTemplate 
(http://py-templates.sourceforge.net/htmltemplate/index.html;)
is a minimal templating system for fill-in-the-blanks template work in 
Python.

Actually, if you have HTMLTemplate, FCGI, and MySQLdb, you have enough to
do a back-end database.

   There are some advantages to libraries (you call them) over 
frameworks

(they call you) if you're doing something unusual.  Frameworks are more
useful if you're doing yet another Web 2.0 web site.

John Nagle

/div



Thanks for the advice John.  I am concerned at what you say about the 
uptake of 3.x - you could be right (although I hope you eventually 
turn-out to be wrong :-) ).


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


Python 2.6 Global Variables

2009-10-28 Thread mattofak
Hi All;

I'm new to Python and moving from C, which is probably a big source of
my confusion. I'm struggling with something right now though and I
hope you all can help.

I have a global configuration that I would like all my classes and
modules to be able to access. What is the correct way to do this?

Thanks;
Matthew Walker
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Web development with Python 3.1

2009-10-28 Thread Alan Harris-Reid


Martin v. Löwis wrote:

I am very much new to Python, and one of my first projects is a simple
data-based website. I am starting with Python 3.1 (I can hear many of
you shouting don't - start with 2.6), but as far as I can see, none of
the popular python-to-web frameworks (Django, CherryPy, web.py, etc.)
are Python3 compatible yet.



That's not entirely true, see

http://wiki.python.org/moin/PortingDjangoTo3k

Regards,
Martin
  


Interesting link.  Thanks for the info.

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


Re: Bug(s) in Python 3.1.1 Windows installation

2009-10-28 Thread Alf P. Steinbach

* Mark Hammond:

On 29/10/2009 11:06 AM, Alf P. Steinbach wrote:


So I suggest switching to some other more light-weight installer
technology.


Thanks for the suggestion, but I expect we will stick with MSI even with 
its shortcomings.  Using MSI files has significant other advantages, 
particularly in managed environments.


Hm, yes, isn't that always so...



(2) Failure to set up PATH.


This is by design.  If you really care passionately about this, you 
should be able to find a number of discussions here, in python-dev and 
in the python bug tracker.


One example of why the current behaviour is useful is that many people 
install multiple Python versions side-by-side and a last installed 
wins strategy isn't a great option.


This rationale is then inconsistent with the installer setting up file 
associations (the same argument should apply there if it was valid).


But please don't remove the setting up of file associations, for it would then 
require any novice to learn about paths and directories and the Windows registry 
and whatnot before even creating first program.


A reasonable solution is, I think, to check and give the user the choice, with 
default to Just Do It if there is no apparent conflict. :-)




Even after setting up a correct PATH Tkinter does not work:


I suspect this will be a Python 3.x issue - you probably want to stick 
with 2.x.


Ethan Furman suggested that in Python 3.x the name was changed to all lowercase 
tkinter, and that worked...


I don't understand how it works, yet, since there's no file [tkinter.*] 
anywhere, but, it works! :-)


Summarizing the main differences 2.6 - 3.1.1 that I know of so far: print is 
now a function (nice), / now always produces float result (unsure about that, 
it must surely break a lot or even most of existing code?), xrange() has been 
removed and range() now works like old xrange().



Cheers,

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


Re: Python 2.6 Global Variables

2009-10-28 Thread Ronn Ross
Inside the method that you want to use  the var prefix the first  
instance with global. For example: global my_var. Then you can use the  
var like normal in the method. Good luck


On Oct 28, 2009, at 20:50, mattofak matto...@gmail.com wrote:


Hi All;

I'm new to Python and moving from C, which is probably a big source of
my confusion. I'm struggling with something right now though and I
hope you all can help.

I have a global configuration that I would like all my classes and
modules to be able to access. What is the correct way to do this?

Thanks;
Matthew Walker
--
http://mail.python.org/mailman/listinfo/python-list

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


Re: Python 2.6 Global Variables

2009-10-28 Thread Chris Rebert
 On Oct 28, 2009, at 20:50, mattofak matto...@gmail.com wrote:
 Hi All;

 I'm new to Python and moving from C, which is probably a big source of
 my confusion. I'm struggling with something right now though and I
 hope you all can help.

 I have a global configuration that I would like all my classes and
 modules to be able to access. What is the correct way to do this?

On Wed, Oct 28, 2009 at 6:02 PM, Ronn Ross ronn.r...@gmail.com wrote:
 Inside the method that you want to use  the var prefix the first instance
 with global. For example: global my_var. Then you can use the var like
 normal in the method. Good luck

Note that without a global declaration, functions can still read
global variables and modify the objects associated with them, but will
be unable to re-bind (i.e. reassign) entirely different objects to
global variables; the `global` statement just permits them to rebind
global variables to new values.

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


Re: Form Parsing resouces

2009-10-28 Thread Tim Johnson
On 2009-10-28, Gabriel Genellina gagsl-...@yahoo.com.ar wrote:
...
 Try FormEncode http://formencode.org/
Wish I had noticed that yesterday. I started rolling my own and am
about 2/3's way thru.
thanks
-- 
Tim 
t...@johnsons-web.com
http://www.akwebsoft.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2.6 Global Variables

2009-10-28 Thread Benjamin Kaplan
On Wed, Oct 28, 2009 at 8:50 PM, mattofak matto...@gmail.com wrote:
 Hi All;

 I'm new to Python and moving from C, which is probably a big source of
 my confusion. I'm struggling with something right now though and I
 hope you all can help.

 I have a global configuration that I would like all my classes and
 modules to be able to access. What is the correct way to do this?


Make a separate module with all the config stuff in it, and import
that module everywhere you need it. Just make sure you do import
settings and not from settings import *. The behavior is different.
In the first case, one instance of the module is shared among every
module that imports it, so any changes you make will appear in all
modules. IN the second case, the current values in settings.py are
copied into the local namespace. Changes made in one module won't
appear in the other modules.

 Thanks;
 Matthew Walker
 --
 http://mail.python.org/mailman/listinfo/python-list

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


Re: Bug(s) in Python 3.1.1 Windows installation

2009-10-28 Thread David Robinow
On Wed, Oct 28, 2009 at 8:06 PM, Alf P. Steinbach al...@start.no wrote:
 PS: This was not unexpected. It was exactly why I earlier didn't even look
 at CPython (umpteen bad experiences with *nix ports) but used ActivePython.

It's not a *nix port. It's multiplatform and it works fine. As you've
been told before, ActivePython is cpython.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: popen function of os and subprocess modules

2009-10-28 Thread Sean DiZazzo
On Oct 28, 7:15 am, banu varun.nagp...@gmail.com wrote:
 On Oct 28, 3:02 pm, Jon Clements jon...@googlemail.com wrote:



  On 28 Oct, 13:39, banu varun.nagp...@gmail.com wrote:

   Hi,
   I am a novice in python. I was trying to write a simple script on
   Linux (python 3.0) that does the following

   #cd directory
   #ls -l

   I use the following code, but it doesn't work:

   import os
   directory = '/etc'
   pr = os.popen('cd %s' % directory,'w')
   pr.close()
   pr = os.popen('ls -l','w')                                      #
   prints the content of present folder and not '/etc'
   pr.close()

   Can anyone suggest me how to fix this simple script? Also what is the
   use of read(), readlines() and write() functions?

   Now, I also read in the online python documentation that os.popen is
   deprecated and no longer recommended in pyhton 3.0. Instead they ask
   to use subprocess.popen. I am not able to figure out how to accomplish
   my task with subprocess.poepn also. Can anyone suggest please?

   Regards
   Varun

  If you're only trying to get the contents of a directory, there are
  more suitable functions - you don't need a separate process. The popen*
  () commands are deprecated.

  Try using os.listdir() - can't remember off the top of my head if
  that's been moved to os.path.listdir() in the 3.* series, but a read
  of the doc's will set you straight.

  Ditto for read() and write().

  If you describe what you're trying to achieve, maybe we can help more.

  Also, if you're using 3.0, may I suggest moving to 3.1?

  hth,

  Jon.

 Thanks for the reply Jon
 Basically I need to move into a folder and then need to execute some
 shell commands(make etc.) in that folder. I just gave 'ls' for the
 sake of an example. The real problem I am facing is, how to stay in
 the folder after popen('cd directory') finishes. It seems trivial, but
 I am not able to do it.

 Varun

Use subprocess.Popen() with it's cwd argument.  Something like:

import subprocess
p = subprocess.Popen([ls,-l] stdout=subprocess.PIPE, cwd=/etc)

print p.stdout.read()

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


Re: Bug(s) in Python 3.1.1 Windows installation

2009-10-28 Thread Alf P. Steinbach

* David Robinow:

On Wed, Oct 28, 2009 at 8:06 PM, Alf P. Steinbach al...@start.no wrote:

PS: This was not unexpected. It was exactly why I earlier didn't even look
at CPython (umpteen bad experiences with *nix ports) but used ActivePython.


It's not a *nix port. It's multiplatform and it works fine.


Your works fine is in blatant contradiction with reality, as reported here.



As you've
been told before, ActivePython is cpython.


Thanks for that point of view, but ActivePython just works without any hassle, 
while CPython does not.


As far as I'm concerned you can call the beast whatever you want, e.g. 
multiplatform. But don't expect me to use your terminology just to please you 
and make it seem nicer than it is. I think that's an outrageous request, on the 
same level of outrageousness as the denial of reality that you engaged in above.


That said -- which is all about your comments, not about Python -- I rather like 
the 3.1.1 thing so far. It could do with a much better installer, the packaging, 
which is what I tested now. But since 2.6 is a transitional ease-the-porting 
version, 3.x is automatically a much more clean language, and it seems better.



Cheers  hth.,

- Alf


PS: Please don't mail me copies of your replies. This time it made me first 
e-mail and then have to copy that for the in-group reply. It does fit in with 
your denial of reality and insistence that others should use the terms that you 
like the best, the non-thinking or trolling (not much difference in practice) 
approach to dealing with things, but even if it fits so well please don't do it.

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


Re: Bug(s) in Python 3.1.1 Windows installation

2009-10-28 Thread John Machin
On Oct 29, 11:56 am, Alf P. Steinbach al...@start.no wrote:
 Summarizing the main differences 2.6 - 3.1.1 that I know of so far: print is
 now a function (nice), / now always produces float result (unsure about 
 that,
 it must surely break a lot or even most of existing code?), xrange() has been
 removed and range() now works like old xrange().

http://www.python.org/doc/3.0/whatsnew/3.0.html
http://www.python.org/doc/3.1/whatsnew/3.1.html

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


__eq__() inconvenience when subclassing set

2009-10-28 Thread Jess Austin
I'm subclassing set, and redefining __eq__().  I'd appreciate any
relevant advice.

 class mySet(set):
... def __eq__(self, other):
... print called mySet.__eq__()!
... if isinstance(other, (set, frozenset)):
... return True
... return set.__eq__(self, other)
...

I stipulate that this is a weird thing to do, but this is a toy class
to avoid the lengthy definition of the class I actually want to
write.  Now I want the builtin set and frozenset types to use the new
__eq__() with mySet symmetrically.

 mySet() == set([1])
called mySet.__eq__()!
True
 mySet() == frozenset([1])
called mySet.__eq__()!
True
 set([1]) == mySet()
called mySet.__eq__()!
True
 frozenset([1]) == mySet()
False

frozenset doesn't use mySet.__eq__() because mySet is not a subclass
of frozenset as it is for set.  I've tried a number of techniques to
mitigate this issue. If I multiple-inherit from both set and
frozenset, I get the instance lay-out conflict error.  I have similar
problems setting mySet.__bases__ directly, and hacking mro() in a
metaclass.  So far nothing has worked.  If it matters, I'm using 2.6,
but I can change versions if it will help.

Should I give up on this, or is there something else I can try?  Keep
in mind, I must redefine __eq__(), and I'd like to be able to compare
instances of the class to both set and frozenset instances.

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


cool-compiling python 3

2009-10-28 Thread Rustom Mody
I guess this is a bit OT but anyhow.

I just finished compiling compiling python 3 on ubuntu and
discovered that my laptop has a builtin toaster :-;

Yeah I know this is not a python issue and probably modern laptops are
meant to run wondrous beautiful elephantaneous things like eclipse
cool-ly but heat up on a few gccs!

Still does anyone know how/what/where I can tell ubuntu to run slow and cool?

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


Re: Building Python on Solaris 10?

2009-10-28 Thread ryles
On Oct 28, 3:46 pm, Judy Booth j...@invalid.invalid wrote:
 Can anyone point me towards some instructions for building Python on
 Solaris 10?
 We need this for some of our test scripts and so far we cannot get this
 to build.

 We have tried both Python 2.6.4 and 3.1.1 and both fail with messages
 like this:
 Include/pyport.h:685:2: #error LONG_BIT definition appears wrong for
 platform (bad gcc/glibc config?).
 *** Error code 1
 make: Fatal error: Command failed for target `Modules/python.o'

 The configure command used is:
 ./configure --with-universal-archs=64-bit --enable-universalsdk
 LDFLAGS=-s
 -L/usr/local/lib -L/opt/ssl/lib -lgcc --prefix=/opt/python
 --prefix=${PREFIX}

 and the compiler version is gcc 3.4.3.

 A search on Google showed this up as a problem several years ago and
 suggested that there might be a problem with the way configure is working
 on Solaris.

 If anyone can help with this that would be great.

 Thanks,

 Judy

We never heard back from the OP of this thread, but you might try
building with cc instead of gcc:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/bf109ba2c86c3715
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Working threads progress

2009-10-28 Thread ryles
On Oct 28, 7:02 pm, mattia ger...@gmail.com wrote:
 Now, I would like to know the activity done (e.g. every two seconds) so I
 create another thread that checks the queue size (using .qsize()). Have
 you any suggestion to improve the code?

It's not uncommon to pass each thread a second queue for output, which
in your case might be tuples of (item, result). You can read from this
queue in a single thread, and since the results now accumulate
incrementally, you can easily collect more detailed status/progress
information (if that's what you're looking for).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: __eq__() inconvenience when subclassing set

2009-10-28 Thread Mick Krippendorf
Jess Austin schrieb:
  frozenset([1]) == mySet()
 False
 
 frozenset doesn't use mySet.__eq__() because mySet is not a subclass
 of frozenset as it is for set.

You could just overwrite set and frozenset:

class eqmixin(object):
def __eq__(self, other):
print called %s.__eq__() % self.__class__
if isinstance(other, (set, frozenset)):
return True
return super(eqmixin, self).__eq__(other)

class set(eqmixin, set):
pass
class frozenset(eqmixin, frozenset):
pass
class MySet(set):
pass


Regards,
Mick.
-- 
http://mail.python.org/mailman/listinfo/python-list


How to test if a file is a symbolic link?

2009-10-28 Thread Peng Yu
'symbolic_link' is a symbolic link in the current directory. I run
'python main.py', but it does not return me anything. I want to check
if a file is a symbolic link. I'm wondering what is the correct way to
do so?

$cat main.py
import stat
import os

st = os.stat('symbolic_link')
if stat.S_ISLNK(st.st_mode):
  print Hello
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Feedback wanted on programming introduction (Python in Windows)

2009-10-28 Thread Richard Heathfield
In mpg.255244b37d76cfb5989...@news.eternal-september.org, Dann 
Corbit wrote:

 In article hc8pn3$dd...@news.eternal-september.org, al...@start.no
 says...
 

snip

 here's the public view of ch 1
 (complete) and ch 2 (about one third completed, I've not yet
 settled on a title so it's just chapter asd):
 
  http://preview.tinyurl.com/progintro
 
 Cheers,
 
 Why is chapter 2 called ASD?

Presumably its subtitle is Introducing UPPER CASE.

-- 
Richard Heathfield http://www.cpax.org.uk
Email: -http://www. +rjh@
Usenet is a strange place - dmr 29 July 1999
Sig line vacant - apply within
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Feedback wanted on programming introduction (Python in Windows)

2009-10-28 Thread Richard Heathfield
In mpg.255246264331509a989...@news.eternal-september.org, Dann 
Corbit wrote:

snip
 
 You can read PDF with the ghostscript stuff or the free Adobe stuff.

Agreed. But why should you have to?

 A man who cannot read .pdf or .ps in today's computer science world
 is a crippled man (IMO-YMMV).

A man who doesn't particularly enjoy relying on proprietary non-text 
formats, however, is not crippled, just cautious.

A man who cannot express what he needs to express /without/ resorting 
to .pdf format is computer-illiterate.

snip

-- 
Richard Heathfield http://www.cpax.org.uk
Email: -http://www. +rjh@
Usenet is a strange place - dmr 29 July 1999
Sig line vacant - apply within
-- 
http://mail.python.org/mailman/listinfo/python-list


Minifb 1.2 released

2009-10-28 Thread peteshinners
I've released version 1.2 of my simple Facebook module, minifb.
http://code.google.com/p/minifb/

This is a minimalist API for validating and making calls to Facebook.
The new release fixes a few outstanding problems, and adds support for
Python 3. Because the module isn't too large, writing it in a syntax
that works on Python2 and Python3 didn't require anything (too) messy.

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


Re: How to test if a file is a symbolic link?

2009-10-28 Thread D'Arcy J.M. Cain
On Wed, 28 Oct 2009 22:19:55 -0500
Peng Yu pengyu...@gmail.com wrote:
 'symbolic_link' is a symbolic link in the current directory. I run
 'python main.py', but it does not return me anything. I want to check
 if a file is a symbolic link. I'm wondering what is the correct way to
 do so?
 
 $cat main.py
 import stat
 import os

As soon as you import os the OS that you are running is relevant.  I'll
assume some sort of Unix.

 st = os.stat('symbolic_link')

The os module uses the underlying OS calls.  run man 2 stat to see
what stat does.  I think you will find that lstat is what you want.

-- 
D'Arcy J.M. Cain da...@druid.net |  Democracy is three wolves
http://www.druid.net/darcy/|  and a sheep voting on
+1 416 425 1212 (DoD#0082)(eNTP)   |  what's for dinner.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to test if a file is a symbolic link?

2009-10-28 Thread tec

On 2009-10-29 11:19, Peng Yu wrote:

'symbolic_link' is a symbolic link in the current directory. I run
'python main.py', but it does not return me anything. I want to check
if a file is a symbolic link. I'm wondering what is the correct way to
do so?

$cat main.py
import stat
import os

st = os.stat('symbolic_link')
if stat.S_ISLNK(st.st_mode):
   print Hello


Use os.lstat instead of os.stat to prevent following symbolic links.

Or more directly, use os.path.islink()

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


Re: How to test if a file is a symbolic link?

2009-10-28 Thread Steven D'Aprano
On Wed, 28 Oct 2009 22:19:55 -0500, Peng Yu wrote:

 'symbolic_link' is a symbolic link in the current directory. I run
 'python main.py', but it does not return me anything. I want to check if
 a file is a symbolic link. I'm wondering what is the correct way to do
 so?
 
 $cat main.py
 import stat
 import os
 
 st = os.stat('symbolic_link')
 if stat.S_ISLNK(st.st_mode):
   print Hello


I believe os.stat follows links, so you're testing if the original file 
is a symbolic link.

You want to use os.lstat, or the os.path.islink() function.


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


Fix problems with email list

2009-10-28 Thread Spencer Heckathorn
I am getting doubles of every email on this list. Is there a list manager I
can inform?

 

Please help this is getting very annoying and makes it very hard to follow
along.

 

Spencer

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


Re: How to test if a file is a symbolic link?

2009-10-28 Thread ma

import os

if os.path.islink('symbolic_link'):
print hello.

Cheers,
Mahmoud Abdelkader

On Oct 28, 2009, at 11:19 PM, Peng Yu pengyu...@gmail.com wrote:


'symbolic_link' is a symbolic link in the current directory. I run
'python main.py', but it does not return me anything. I want to check
if a file is a symbolic link. I'm wondering what is the correct way to
do so?

$cat main.py
import stat
import os

st = os.stat('symbolic_link')
if stat.S_ISLNK(st.st_mode):
 print Hello
--
http://mail.python.org/mailman/listinfo/python-list

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


Re: How to test if a file is a symbolic link?

2009-10-28 Thread Ben Finney
Peng Yu pengyu...@gmail.com writes:

 'symbolic_link' is a symbolic link in the current directory. I run
 'python main.py', but it does not return me anything. I want to check
 if a file is a symbolic link.

You have the same access to the Python help as we do:

 import os.path
 help(os.path)

You have the same access to the Python documentation search facility as
we do: URL:http://docs.python.org/library/os.path.html.

So I'm puzzled: why do you bring so very many questions to this group
that are answered quickly by an obvious search of the standard library?

-- 
 \ “I've always wanted to be somebody, but I see now that I should |
  `\   have been more specific.” —Jane Wagner, via Lily Tomlin |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: calling server side function

2009-10-28 Thread Tim Arnold
Gabriel Genellina gagsl-...@yahoo.com.ar wrote in message 
news:mailman.2155.1256716617.2807.python-l...@python.org...
 En Wed, 28 Oct 2009 04:04:50 -0300, Paul Hartley luapyelt...@hotmail.com 
 escribió:

 I have a socket set up between a client and server program.  Let's say 
 that I serialize (pickle) some data in the client and send it to the 
 server with the intention of calling a function in the server to process 
 the data.  How would one execute the function?  This is not for a 
 web-based application, BTW -- it's a desktop based application
 My current thought process is (using a generalized example):
 I have a list of numbers in the client and want to find the length of 
 the list using the server.  There exists a function find_len() in the 
 server code.  I have a list of numbers [1,2,3].  On the client side, I 
 create the tuple (find_len, [1,2,3]), and serialize it.  I pass this 
 serialized object via a socket to the server, which unpickles it.  The 
 server takes the key (find_len) and uses a getattr call to get the 
 find_len function.  The server then calls find_len([1,2,3]) to get the 
 sum.
 def find_len(list_):return
 Are there better ways of accomplishing this (I'm aware that there are 
 security pitfalls here...)

 xmlrpc does more or less the same thing, but serializing in xml instead of 
 pickling.

 -- 
 Gabriel Genellina


Also, have a look at RPyc. I've been playing with it for a few days and it 
sounds it may be what you're after.
http://rpyc.wikidot.com/
http://www.ibm.com/developerworks/linux/library/l-rpyc/index.html

--Tim Arnold


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


Re: a simple unicode question

2009-10-28 Thread Tim Arnold
Chris Jones cjns1...@gmail.com wrote in message 
news:mailman.2149.1256707687.2807.python-l...@python.org...
 On Tue, Oct 27, 2009 at 06:21:11AM EDT, Lie Ryan wrote:
 Chris Jones wrote:

 [..]

 Best part of Unicode is that there are multiple encodings, right? ;-)

 No, the best part about Unicode is there is no encoding!

 Unicode does not define any encoding;

 RFC 3629:

 ISO/IEC 10646 and Unicode define several encoding forms of their
 common repertoire: UTF-8, UCS-2, UTF-16, UCS-4 and UTF-32.

 what it defines is code-points for  characters which is not related to
 how characters are encoded in files or network transmission.

 In other words, Unicode is not related to any encoding .. and yet the
 UTF-8, UTF-16.. encoding forms are clearly related to Unicode.

 How is that possible?

 CJ

When I first saw it, my first thought was that the subjectline was an 
oxymoron.

--Tim Arnold


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


Re: Bug(s) in Python 3.1.1 Windows installation

2009-10-28 Thread John Machin
On Oct 29, 11:06 am, Alf P. Steinbach al...@start.no wrote:
 (3) Tkinter not bundled, misleading  incomplete documentation.

 With the file associations in place (the installer managed to do that) running
 console programs works fine.

 However, running Tkinter based programs does *not* work:

 code filename=ellipse.pyw
 import Tkinter

What documentation are you reading? As you are running Python 3.1, you
might like to consider reading 3.1 documentation. Many things have
been changed from 2.X, including renaming unconventionally named
modules and packages. In particular see 
http://docs.python.org/3.1/library/tkinter.html
... in general, see the whatsnew docs that I pointed you at.

If you are trying to run 2.X code under 3.1, don't expect it to work
straight away. Find 2to3 in the docs.


[snip]

 Checking I find that while there is a Tkinter folder there is no file
 [Tkinter.py] in this installation, i.e. the Tkinter module is not bundled with
 this distribution.

but the tkinter module is bundled


 That's bad news for any novice wanting to start learning the language: a main
 battery is missing! The documentation gives the impression that Tkinter can

Which documentation?


 just be used, and it could just be used with ActivePython. Here the novice has

ActivePython 2.X or 3.X?

 to figure out not only that it isn't there, but also how to get it!

 Checking url:http://pypi.python.org/pypi/, the package index, nope, no
 Tkinter there.

PyPI is for third-party modules and packages.


 Typing tkinter in the Firefox address bar leads to 
 url:http://wiki.python.org/moin/TkInter, and it has a recipe for checking 
 for
 Tkinter support/installation:

 checking results
 Python 3.1.1 (r311:74483, Aug 17 2009, 17:02:12) [MSC v.1500 32 bit (Intel)] 
 on
 win32
 Type help, copyright, credits or license for more information.
   import _tkinter
   import Tkinter
 Traceback (most recent call last):
    File stdin, line 1, in module
 ImportError: No module named Tkinter
  
 /checking results

 The recipe now calls for adding path to directory with [Tkinter.py], but as
 mentioned no such file in this installation...

 Cheers,

 - Alf

 PS: This was not unexpected. It was exactly why I earlier didn't even look at
 CPython (umpteen bad experiences with *nix ports) but used ActivePython. I'm
 hopeful that I will find where Tkinter resides on the net, but hey, it should 
 at
 least be documented, up front I mean (it's possibly mentioned somewhere, 
 yes?).

Yes. You'll find that tkinter resides also on your hard disk (unless
you chose not to install it).

Python 3.1.1 (r311:74483, Aug 17 2009, 17:02:12) [MSC v.1500 32 bit
(Intel)] on
win32
Type help, copyright, credits or license for more information.
 import tkinter
 tkinter.__file__
'C:\\python31\\lib\\tkinter\\__init__.py'

Didn't you do a search of your hard disk for Tkinter?


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


Re: What IDE has good git and python support?

2009-10-28 Thread alex23
On Oct 28, 1:56 am, Aweks a...@ewadev.com wrote:
 what do you use?

ActiveState's Komodo IDE.
-- 
http://mail.python.org/mailman/listinfo/python-list


Newbie advice

2009-10-28 Thread CSharpner
Alright, I'm not new to programming, but I'm diving in head first into
Python for the first time.  I'm running on Windows 7, just installed
Eclipse Java EE IDE for Web Developers and installed PyDev in it and
installed Python 2.6.  I've written my first Hello World program,
which simply displays Hello World! in the console output.

Here's what I /want/ to do, but don't know where to begin:

- Write web services in Python (I've done plenty of this in .NET,
BTW).
- Write plain DLLs (is that even an option in Python (I told you I was
a newb to Python, didn't I? :))
- Write a web app (HTML front end, Python web services called from
JavaScript).
- Write a plain old web app with Python (no web services or Ajax, just
plain HTML  Python).
- Is it possible to create a Windows client desktop GUI app with
Python?  How?  How 'bout a Linux GUI app?

I don't know how to create and write a Python project with Eclipse to
tell it to be a web service or a web app, or if what I need to do in
the code to make as such, no run it from Eclipse to launch the app
in a web server and launch a browser automatically.  Can I debug after
doing this?  In other words, can I put break points in my web services
or web apps and go back into the IDE to step through the code for web
services and web apps?

Also, I'm not tied to Eclipse.  I'm totally open to other IDEs as
well.  SharpDevelop with the Python plugin looks interesting too.

And finally, I'm not completely committed to using Windows to host my
development either.  I'm willing to use Linux too (but would prefer
Windows... at least to get started, until I'm comfortable enough with
Python).

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


What exception shall I raise when os.path.exists fails?

2009-10-28 Thread Peng Yu
I want to raise an exception when os.path.exists fails. I looked
through the exception list on the menu. I'm not sure if IOError is the
most appropriate exception I should use. Could somebody let me know?
Thank you!

import os.path

def direct_target(path):
  while os.path.islink(path):
path = os.path.join(os.path.dirname(path), os.readlink(path))

  if not os.path.exists(path):
raise IOError
  else:
return path
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: What exception shall I raise when os.path.exists fails?

2009-10-28 Thread Chris Rebert
On Wed, Oct 28, 2009 at 10:01 PM, Peng Yu pengyu...@gmail.com wrote:
 I want to raise an exception when os.path.exists fails. I looked
 through the exception list on the menu. I'm not sure if IOError is the
 most appropriate exception I should use. Could somebody let me know?

Yeah, I'd say IOError:

Python 2.6.2 (r262:71600, May 14 2009, 16:34:51)
[GCC 4.0.1 (Apple Inc. build 5484)] on darwin
Type help, copyright, credits or license for more information.
 f=file('nonexistent', 'r')
Traceback (most recent call last):
  File stdin, line 1, in module
IOError: [Errno 2] No such file or directory: 'nonexistent'

ValueError would also be a justifiable choice; the caller gave a value
for a filepath that was invalid in that it was non-existent.

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


Re: Bug(s) in Python 3.1.1 Windows installation

2009-10-28 Thread Alf P. Steinbach

* John Machin:

On Oct 29, 11:06 am, Alf P. Steinbach al...@start.no wrote:

(3) Tkinter not bundled, misleading  incomplete documentation.

With the file associations in place (the installer managed to do that) running
console programs works fine.

However, running Tkinter based programs does *not* work:

code filename=ellipse.pyw
import Tkinter


What documentation are you reading? As you are running Python 3.1, you
might like to consider reading 3.1 documentation. Many things have
been changed from 2.X, including renaming unconventionally named
modules and packages. In particular see 
http://docs.python.org/3.1/library/tkinter.html
... in general, see the whatsnew docs that I pointed you at.


Thanks. I wasn't expecting that the names used to access some library had 
changed just because the core language had been changed, and I didn't notice 
this little change of letter case  --  but Ethan Furman set me straight on that 
earlier, as I reported else-thread. I'm new to the language.




If you are trying to run 2.X code under 3.1, don't expect it to work
straight away. Find 2to3 in the docs.


Thanks again!

I don't see how 2to3 can fix up / operators without having static type 
information. In the case of integer args / should be replaced with // (as I 
understand it), while for floats it should be left alone as-is. Hm.


It seems to me that Pyrex has demonstrated that declarations *can* be combined 
sort of naturally with the rest of the language. What I miss most is the kind of 
 force-use-of-declarations directive like Perl use strict or VBScript option 
explicit. Of course that would require some way to declare variables, at least 
their names... But perhaps this is already in 3.x? I'll probably find out.





[snip]

Checking I find that while there is a Tkinter folder there is no file
[Tkinter.py] in this installation, i.e. the Tkinter module is not bundled with
this distribution.


but the tkinter module is bundled


That's bad news for any novice wanting to start learning the language: a main
battery is missing! The documentation gives the impression that Tkinter can


Which documentation?


I see that the docs installed with 3.1.1 uses all lowercase in the code.

But the tutorials etc. on the net, referenced from the 3.1.1 documentation, have 
not been updated to mention that they're not version-inpendent any longer.


E.g. url: http://infohost.nmt.edu/tcc/help/pubs/tkinter/ (which says it is a 
reference), and others referenced from the 3.1.1 documentation (I think the 
3.1.1 documentation should clearly state that the referenced get-the-details 
external documentation is for an earlier version of Python).




just be used, and it could just be used with ActivePython. Here the novice has


ActivePython 2.X or 3.X?


2.6, I couldn't find any later ActivePython version.

Of course it works just fine in 3.x when one writes lowercase tkinter.




to figure out not only that it isn't there, but also how to get it!

Checking url:http://pypi.python.org/pypi/, the package index, nope, no
Tkinter there.


PyPI is for third-party modules and packages.


Does that mean that Tkinter is *not* third-party, but now part of the language 
like part of its standard library?




Typing tkinter in the Firefox address bar leads to 
url:http://wiki.python.org/moin/TkInter, and it has a recipe for checking for
Tkinter support/installation:

checking results
Python 3.1.1 (r311:74483, Aug 17 2009, 17:02:12) [MSC v.1500 32 bit (Intel)] on
win32
Type help, copyright, credits or license for more information.
  import _tkinter
  import Tkinter
Traceback (most recent call last):
   File stdin, line 1, in module
ImportError: No module named Tkinter
 
/checking results

The recipe now calls for adding path to directory with [Tkinter.py], but as
mentioned no such file in this installation...

Cheers,

- Alf

PS: This was not unexpected. It was exactly why I earlier didn't even look at
CPython (umpteen bad experiences with *nix ports) but used ActivePython. I'm
hopeful that I will find where Tkinter resides on the net, but hey, it should at
least be documented, up front I mean (it's possibly mentioned somewhere, yes?).


Yes. You'll find that tkinter resides also on your hard disk (unless
you chose not to install it).

Python 3.1.1 (r311:74483, Aug 17 2009, 17:02:12) [MSC v.1500 32 bit
(Intel)] on
win32
Type help, copyright, credits or license for more information.

import tkinter
tkinter.__file__

'C:\\python31\\lib\\tkinter\\__init__.py'


Hey, that's very useful! :-)



Didn't you do a search of your hard disk for Tkinter?


Yes, it only found a folder and some DLLs, I think it was.

But given the filename you showed above I now found out about packages in 
Python.

I guess it's the stumble-upon principle at work. g


Cheers,

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


[issue7227] Shell Support for installation of Python Packages (.EGG)

2009-10-28 Thread Martin v . Löwis

Changes by Martin v. Löwis mar...@v.loewis.de:


--
versions:  -Python 2.4, Python 2.5, Python 2.6, Python 3.0, Python 3.1

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7227
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7228] %lld for PyErr_Format (Modules/_io/bufferedio.c)

2009-10-28 Thread Hirokazu Yamamoto

New submission from Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp:

Hello. There is following sentence in Modules/_io/bufferedio.c,

  PyErr_Format(PyExc_IOError,
   Raw stream returned invalid position % PY_PRIdOFF,
 (PY_OFF_T_COMPAT)n);

and PY_PRIdOFF == lld when sizeof(off_t) == sizeof(long long).

But it seems that PyErr_Format doesn't support lld as specifier.

I noticed this because
# define PY_OFF_T_COMPATlong long
caused compile error on my good old VC6. ;-) (VC6 doesn't have it)

--
messages: 94601
nosy: mark.dickinson, ocean-city
severity: normal
status: open
title: %lld for PyErr_Format (Modules/_io/bufferedio.c)
versions: Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7228
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7228] %lld for PyErr_Format (Modules/_io/bufferedio.c)

2009-10-28 Thread Hirokazu Yamamoto

Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp added the comment:

I believe r75728 and r75879 are related.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7228
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4750] tarfile keeps excessive dir structure in compressed files

2009-10-28 Thread Tarek Ziadé

Tarek Ziadé ziade.ta...@gmail.com added the comment:

Lars, is this still accurate ?

--
nosy: +tarek
versions: +Python 3.1, Python 3.2 -Python 2.5

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue4750
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4750] tarfile keeps excessive dir structure in compressed files

2009-10-28 Thread Tarek Ziadé

Changes by Tarek Ziadé ziade.ta...@gmail.com:


--
components:  -Distutils

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue4750
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7228] %lld for PyErr_Format (Modules/_io/bufferedio.c)

2009-10-28 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

Thanks for reporting this.

Do you know what the right conversion specifier is for print(f)ing 
something of long long type in MSVC?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7228
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7228] %lld for PyErr_Format (Modules/_io/bufferedio.c)

2009-10-28 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

The 'long long' define should have been PY_LONG_LONG.  I don't know what 
the appropriate substitute for %lld is, though.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7228
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7228] %lld for PyErr_Format (Modules/_io/bufferedio.c)

2009-10-28 Thread Hirokazu Yamamoto

Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp added the comment:

MSVC6 uses __int64 as 64bit integer, and printf uses I64 as its specifier.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7228
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7228] %lld for PyErr_Format (Modules/_io/bufferedio.c)

2009-10-28 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

So PY_PRIdOFF should be I64d?  Or just I64?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7228
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7228] %lld for PyErr_Format (Modules/_io/bufferedio.c)

2009-10-28 Thread Hirokazu Yamamoto

Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp added the comment:

Oh, I was late. I agree with msg94605.

printf(%I64d\n, 1I64  40); /* 1099511627776 */

So if PyErr_Format (actually, PyString_FromFormatV) will support
PY_LONG_LONG, I think we can use same technique as PY_FORMAT_SIZE_T like

#define PY_FORMAT_LONG_LONG I64 /* On Windows */
#define PY_FORMAT_LONG_LONG ll  /* On Unix */

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7228
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7228] %lld for PyErr_Format (Modules/_io/bufferedio.c)

2009-10-28 Thread Hirokazu Yamamoto

Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp added the comment:

I was late again...? Hmm, I thought Python tracker told me that somebody
else modified this issue. Anyway, printf can use both %I64 and %I64d
for signed 64bit integer, but should use %I64u for unsigned 64bit
integer AFAIK.

But PyErr_Format actually calls PyString_FromFormatV, and it's not
treating %lld. So probably we should modify PyString_FromFormatV.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7228
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7228] %lld for PyErr_Format (Modules/_io/bufferedio.c)

2009-10-28 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

Thanks.  I'm just going to fix Modules/io/_iomodule.h for now.  But I 
agree that it might make sense to have a PY_FORMAT_OFF_T or 
PY_FORMAT_LONG_LONG in pyport.h, especially if uses of off_t become more 
widespread in the codebase.

I also notice there are some uses of %zd in Modules/io that should be 
replaced with PY_FORMAT_SIZE_T.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7228
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7228] %lld for PyErr_Format (Modules/_io/bufferedio.c)

2009-10-28 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

Aargh.  You're right, of course.  PyString_FromFormatV needs to be 
updated, or avoided in this case.

I'll look at this later today.

--
assignee:  - mark.dickinson

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7228
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7228] %lld for PyErr_Format (Modules/_io/bufferedio.c)

2009-10-28 Thread Hirokazu Yamamoto

Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp added the comment:

Sorry for confusion. I shouldn't have said last 3 lines in msg94601. :-(

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7228
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7212] Retrieve an arbitrary element from a set without removing it

2009-10-28 Thread Willi Richert

Willi Richert w.rich...@gmx.net added the comment:

No particular reason, besides that it is ripped off of pop().

Your solution (omitting register) gives the same performance. Looks
cleaner, of course.

The patch tries to provide a clean way of for x in some_set: break, as
explained above. See the recent python-dev mailing list musings.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7212
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5243] Missing dependency in distutils build

2009-10-28 Thread Patrick Gerken

Patrick Gerken patrick.ger...@computer.org added the comment:

Hi Tarek,

I think clib stuff is installed in the right python directory and the 
ext install step then just finds them.

To reproduce the issue, run 
the old easy_install in a virtualenv.
easy_install ReportLab
It will then fail because of the missing library.

I can also show it during Plone Conference, just look for me in irc.

Thanks,

  Patrick

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5243
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7117] Backport py3k float repr to trunk

2009-10-28 Thread Eric Smith

Eric Smith e...@trueblade.com added the comment:

r75913: Fix _json.c to use PyOS_string_to_double. Change made after
consulting with Bob Ippolito.

This completes the removal of calls to PyOS_ascii_strtod.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7117
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7192] webbrowser.get(firefox) does not work on Mac with installed Firefox

2009-10-28 Thread Ned Deily

Changes by Ned Deily n...@acm.org:


--
assignee:  - ronaldoussoren
components: +Macintosh
nosy: +ronaldoussoren

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7192
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4908] adding a get_metadata in distutils

2009-10-28 Thread Tarek Ziadé

Tarek Ziadé ziade.ta...@gmail.com added the comment:

This patch will be applied for the part that makes DistributionMetadata
load files.

The other part is waiting for PEP 376.

--
priority:  - normal
resolution:  - accepted
versions: +Python 3.2 -Python 3.1

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue4908
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7194] test_thread is flaky

2009-10-28 Thread Ned Deily

Ned Deily n...@acm.org added the comment:

Duplicate of Issue6186?

--
nosy: +ned.deily

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7194
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue6186] test_thread occasionally reports unhandled exceptions on OS X

2009-10-28 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

Ned points out that it may be a duplicate of #7194, which has been fixed.
Can you test with the current trunk or 2.6 branch?

--
nosy: +pitrou

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue6186
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7224] One obvious way to do interning

2009-10-28 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

A simple way to try and see a difference would be to import lot of modules.

By the way, you shouldn't call it _PySet_Add(), it would cause confusion
with the existing PySet_Add(). _PySet_Intern() would be fine.

--
nosy: +pitrou

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7224
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7227] Shell Support for installation of Python Packages (.EGG)

2009-10-28 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
assignee:  - tarek
components: +Distutils -Demos and Tools
nosy: +tarek
priority:  - normal

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7227
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7175] unify pydistutils.cfg and distutils.cfg and use .local

2009-10-28 Thread Ned Deily

Ned Deily n...@acm.org added the comment:

/etc is definitely not the right place to put files for OS X framework 
builds; if necessary, an etc directory could be added under the 
framework version directory as a sibling of bin and lib.  It's also very 
un-OS X like to be putting things into ~/.python and ~/.local 
directories; the usual place would be in somewhere ~/Library, possibly 
~/Library/Application Support/Python or ~/Library/Frameworks.  Keep in 
mind that it's much more likely on OS X to not only have muitiple 
versions of Python installed but also more than one instance of the 
*same* version, for instance, on 10.6, an Apple-supplied 2.6.2 and a 
python.org 2.6.4.  Some thought should be given to locations for the 
files for Unix-style (non-framework) builds.

(Adding Ronald.)

--
nosy: +ned.deily, ronaldoussoren

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7175
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7229] Manual entry for time.daylight can be misleading

2009-10-28 Thread Tomas Kubes

New submission from Tomas Kubes mr_na...@centrum.cz:

Hello,

it is not obvious that the time.daylight data item reports nonzero
values even when DST is currently not being used (ie. in winter) but the
active timezone has DST defined for some other parts of the year.

Current manual entry can be misleadingly interpreted that time.daylight
acts as a current DST idicator (which it does not).

Suggested FIX: Add a sentence:
This value does not idicate that DST is currently active, but rather
describes that current timezone can have DST. Use localtime() dst flag
to determine if DST applies to the given time.


Tomas

--
assignee: georg.brandl
components: Documentation
messages: 94621
nosy: georg.brandl, napik
severity: normal
status: open
title: Manual entry for time.daylight can be misleading
type: feature request
versions: Python 2.4, Python 2.5, Python 2.6, Python 2.7, Python 3.0, Python 
3.1, Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7229
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7175] unify pydistutils.cfg and distutils.cfg and use .local

2009-10-28 Thread Marc-Andre Lemburg

Marc-Andre Lemburg m...@egenix.com added the comment:

Ned Deily wrote:
 
 Ned Deily n...@acm.org added the comment:
 
 /etc is definitely not the right place to put files for OS X framework 
 builds; if necessary, an etc directory could be added under the 
 framework version directory as a sibling of bin and lib.  It's also very 
 un-OS X like to be putting things into ~/.python and ~/.local 
 directories; the usual place would be in somewhere ~/Library, possibly 
 ~/Library/Application Support/Python or ~/Library/Frameworks.  Keep in 
 mind that it's much more likely on OS X to not only have muitiple 
 versions of Python installed but also more than one instance of the 
 *same* version, for instance, on 10.6, an Apple-supplied 2.6.2 and a 
 python.org 2.6.4.  Some thought should be given to locations for the 
 files for Unix-style (non-framework) builds.
 
 (Adding Ronald.)

I think there is a misunderstanding here: we're trying to find
places where distutils would look by default, not where it
would write files.

AFAIK, there is general agreement that when writing files,
Python should use the ~/.local/pythonX.X/ directory.

OTOH, searching for config files that the user creates and
puts in place is another story. Python and distutils only
need to be able to find these and the idea is to use platform
specific standard search paths for this, so that the user
can place those config files into places that feel right on
each platform.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7175
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue7175] unify pydistutils.cfg and distutils.cfg and use .local

2009-10-28 Thread Ned Deily

Ned Deily n...@acm.org added the comment:

I don't think there's a misunderstanding.  By putting, I meant reading 
or writing.  IMO, /etc is not the place on OS X to be looking for 
python-related configuration files, certainly not for framework installs.  
Likewise for ~/.python and ~/.local.  Unfortunately, the latter is already 
out in the field; that was a step in the wrong direction for OS X.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7175
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



<    1   2   3   >