Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-23 Thread prilisauer
By the way, I think I have found the correct wording. 
for my understood, the handover of objects to imported modules doesn't work 
because, e.g. trying to hand-over an SQLite connection into a imported module, 
can't work because the attributes are not transfered.

I'm sorry for my bad english, it's fascinating. 2 years ago I've written very 
large english technical documents for my company. As you can see, the last two 
years I've forgotten a lot and it tooks me some time to get back into.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-23 Thread prilisauer
secondly, it is absolutely not bad meaned, but, why does people post, their 
personal meaning, but nothing about the Posters Problem?

Everybody is free to read or not, but correcting the WWW could became a very 
very big task, (maybe it's easier to climb the 7 summits)

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


Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-23 Thread Cameron Simpson
On 22Dec2012 12:43, prilisa...@googlemail.com prilisa...@googlemail.com wrote:
| I Think I describe my Situation wrong, the written Project is a
| Server, that should store sensor data, perfoms makros on lamps according
| a sequence stored in the DB and Rule systems schould regulate home devices 
and plan scheduler jobs so on.
| 
| The System Runs in a threated environment. It looks for me, like the
| limits are at the end of file. my core problem also the only one I have
| is: I don't know how to get over that limits and enable dataexchange
| like a backbone...

Maybe you should post some of the Perl code, in small pieces. Then we
can suggest ways those poarticular things might be done in Python.

Python threads really easily (with some limitations, but for many purposes
those limitations are irrelevant).

When I have a situation like yours seems to be, I tend to write a few
different items, connected together with a main program. Write modules
that define a class for the things you need to talk to: the database,
the sensors, etc. From the main program, create an instance of the
relevant classes, then dispatch threads doing what needs to be done.

The main program might be shaped like this:

  import db_module  # use a better name
# defines a class called DB to talk to a
# database
  import sensors_module # use a better name
# defines a class called Sensors to report
# sensor values

  def thread_function(db, sensors):
... do something that should happen in a thread ...

  # get some objects to connect to db and sensors
  db = db_module.DB(connection-info-here...)
  sensors = sensors_module.Sensors(sensor-connection-info-here...)

  # set up a Thread and start it
  T = Thread(target=thread_function, args=(db, sensors))
  T.start()
  ... create other threads as needed ...

You see here that:
  - the modules do not know _specifics_ about the db or sensors;
they are told connection info
  - instantiating a class instance:
  db = db_module.DB(connection-info-here...)
passes the specifics
  - you get back a class instance
  - you pass those instances (db, sensors) to the thread_function;
it uses them to access database and sensors

So you see that the modules do not directly share information with each
other. The main program gets objects from each module and hands them to
whoever needs to work with them.

Does this clarify your namespace issues?

Cheers,
-- 
Cameron Simpson c...@zip.com.au

Whatever is not nailed down is mine.  What I can pry loose is not nailed
down. - Collis P. Huntingdon
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python, email temperature

2012-12-23 Thread KarlE
On Saturday, December 22, 2012 9:36:41 PM UTC+1, KarlE wrote:
 Hi!
 
 
 
 Im totally new to Python, and im using it on my Raspberry pi. I found a 
 program that sends an email, and one that checks the temperature of my CPU, 
 but i cant seem to combine the to into the funktion that i want, sending me 
 the CPU temp via Email.
 
 
 
 The two programs work very well on their own, but this doesnt work.
 
 
 
 this works: server.sendmail(fromaddr, toaddrs, msg)  
 
 but this doesnt: server.sendmail(fromaddr, toaddrs, cpu_temperature)
 
 
 
 despite the command print cputemp working in the same program. 
 
 
 
 When i run the program i get the error:  
 
 
 
 Traceback (most recent call last):
 
   File sendcpu.py, line 36, in module
 
 msg = cpu_temperature
 
 NameError: name 'cpu_temperature' is not defined
 
 
 
 Does anyone know why the program claims that cpu_temperature isnt defined, 
 when it is?
 
 
 
 Thanx!
 
 
 
 //Alexander

Ok, im back with a little more understanding of python! I got the program 
working, every time my Raspberry Pi reboots i get an Email containing 
information about the boot and the CPU temperature.

The issue now is that there seems to be a limitation to how long the message 
string can be, about 32 letters. The code below works well, but when i add more 
letters to the string ord and pass about 32 in size the email comes through 
emptpy...

I cant find any information about limitations to strings in Python, or the 
email module. can anyone give me a pointer?

(the code lines my appear with different tabbings due to beeing copied from my 
raspberry pi with Putty, but this is not an issue, all the lines are on the 
same tab)

#!/usr/bin/env python
from __future__ import division
from subprocess import PIPE, Popen
import psutil
import smtplib

def get_cpu_temperature():
process = Popen(['vcgencmd', 'measure_temp'], stdout=PIPE)
output, _error = process.communicate()
return float(output[output.index('=') + 1:output.rindex(')])


def main():
cpu_temperature = get_cpu_temperature()
cpu_usage = psutil.cpu_percent()

ram = psutil.phymem_usage()
ram_percent_used = ram.percent

disk = psutil.disk_usage('/')
disk_percent_used = disk.percent

print 'CPU temperature: ', cpu_temperature

fromaddr = 'xxx'
toaddrs  = 'xxx'
username = 'xxx'
password = 'xxx'

ord = Subject: Pi Boot, CPU:  + str(cpu_temperature)

print len(ord)
server = smtplib.SMTP('smtp.gmail.com:587')
server.starttls()
server.login(username,password)
server.sendmail(fromaddr, toaddrs, ord)
server.quit()

main()

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


Re: Python USB control on Windows 7?

2012-12-23 Thread inq1ltd
On Sunday, December 23, 2012 06:34:41 PM Chris Angelico wrote:
 On Sun, Dec 23, 2012 at 6:28 PM, Tim Roberts t...@probo.com wrote:
  Duncan Booth duncan.booth@invalid.invalid wrote:
 In this year's Christmas Raffle at work I won a 'party-in-a-box'
 including USB fairy lights.
 
 They sit boringly on all the time, so does anyone know if I can toggle
 the power easily from a script? My work PC is running Win7.
 
  Not easily, no.  It's not really a USB device -- I'm betting it doesn't
  even enumerate.  It's just sucking power from the USB wires.  There's
  nothing to control.
 
 Hmm. Can you control whether a particular port is on or off? (I have
 no idea what's possible with the underlying API, much less whether
 it's exposed.) It should in theory be possible - disable the
 appropriate USB port and the device loses power.
 
 ChrisA

If you have the time;

Using communication software, you can control a modem to call, hang up, and 
call again every few seconds. Since you can make a phone do the same thing, 
there is most likely a way to get those lights to respond the same way, at 
least by next Christmas.  

jd






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


Parsing files in python

2012-12-23 Thread Kene Meniru
Hello: I am writing a program that is made up of a collection of POV-Ray 
macros. POV-Ray is available at povray.org. It is a ray-tracing program that 
reads a scene description language (SDL) to create photo-realistic images. At 
this time my program (for modeling building information) is so huge that I am 
finding it difficult managing the macros and I am not even near completion.

I am hoping to move this program to python and am wondering the best way to 
approach this.

I would like to model my program after LaTeX. Basically the user writes a text 
file using certain key words and numbers and my python program reads this file, 
calls the classes that will then work together to calculate the information 
that is needed to create an accurate model. The result of this calculation will 
be an output to another text file in the appropriate format such as POV-Ray 
SDL, OpenSCAD script, etc. This file output can then be rendered by the 
corresponding program to produce the actual 3D model. The macros I have now 
currently does this but like I said it is getting tedious and most importantly 
the fun factor is losing its strength for me.

I have been advised to check out python-ply and I have come across others. I 
have not really tried any yet and before I dive into any one of them I was 
wondering what else I should know. The following is a sample of what the text 
file that will be processed by this proposed system will contain. I appreciate 
any pointers and suggestions. Thank you very much.

possible user file content for parsing 
// in the following the python interface program reads
//+ the contents of the file other.file as if its content
//+ were located at this point.
include other.file

//In the following the python interface makes snap_size a
//+  global parameter
declare snap_size = 10


// In the following buildingLevel is a class that is
//+  called and passed the parameters in parenthesis.
buildingLevel(FirstLevel, 3000)

// In the following snapOffset is a class that is
//+  called and passed the parameters in parenthesis.
snapOffset(Closet-S1_r1, Closet-S2_r3, 0,0,0)
end of user file content

It should also be possible to include comments using double-slashes, etc.

Sincerely,
Kene (kemen...@gmail.com)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python, email temperature

2012-12-23 Thread Mitya Sirenef

On 12/23/2012 08:46 AM, KarlE wrote:

On Saturday, December 22, 2012 9:36:41 PM UTC+1, KarlE wrote:

Hi!



Im totally new to Python, and im using it on my Raspberry pi. I found a program 
that sends an email, and one that checks the temperature of my CPU, but i cant 
seem to combine the to into the funktion that i want, sending me the CPU temp 
via Email.



The two programs work very well on their own, but this doesnt work.



this works: server.sendmail(fromaddr, toaddrs, msg)

but this doesnt: server.sendmail(fromaddr, toaddrs, cpu_temperature)



despite the command print cputemp working in the same program.



When i run the program i get the error:



Traceback (most recent call last):

   File sendcpu.py, line 36, in module

 msg = cpu_temperature

NameError: name 'cpu_temperature' is not defined



Does anyone know why the program claims that cpu_temperature isnt defined, when 
it is?



Thanx!



//Alexander

Ok, im back with a little more understanding of python! I got the program 
working, every time my Raspberry Pi reboots i get an Email containing 
information about the boot and the CPU temperature.

The issue now is that there seems to be a limitation to how long the message string can 
be, about 32 letters. The code below works well, but when i add more letters to the 
string ord and pass about 32 in size the email comes through emptpy...

I cant find any information about limitations to strings in Python, or the 
email module. can anyone give me a pointer?

(the code lines my appear with different tabbings due to beeing copied from my 
raspberry pi with Putty, but this is not an issue, all the lines are on the 
same tab)

#!/usr/bin/env python
from __future__ import division
from subprocess import PIPE, Popen
import psutil
import smtplib

def get_cpu_temperature():
 process = Popen(['vcgencmd', 'measure_temp'], stdout=PIPE)
 output, _error = process.communicate()
 return float(output[output.index('=') + 1:output.rindex(')])


def main():
 cpu_temperature = get_cpu_temperature()
 cpu_usage = psutil.cpu_percent()

 ram = psutil.phymem_usage()
 ram_percent_used = ram.percent

 disk = psutil.disk_usage('/')
 disk_percent_used = disk.percent

 print 'CPU temperature: ', cpu_temperature

 fromaddr = 'xxx'
 toaddrs  = 'xxx'
 username = 'xxx'
 password = 'xxx'

 ord = Subject: Pi Boot, CPU:  + str(cpu_temperature)

 print len(ord)
 server = smtplib.SMTP('smtp.gmail.com:587')
 server.starttls()
 server.login(username,password)
 server.sendmail(fromaddr, toaddrs, ord)
 server.quit()

main()



I'm not sure if Raspberry Pi has it, but usually you want to
use the email module, as in example on this page:

http://docs.python.org/2/library/email-examples.html#email-examples

I think what happens is that because your message starts
with 'Subject:', it's interpreted as subject header instead of
an email. You can try adding two newlines after Subject:,
that might help... but using email module is best if possible.

 -m

--
Lark's Tongue Guide to Python: http://lightbird.net/larks/

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


Re: Python USB control on Windows 7?

2012-12-23 Thread Duncan Booth
Chris Angelico ros...@gmail.com wrote:

 On Sun, Dec 23, 2012 at 6:28 PM, Tim Roberts t...@probo.com wrote:
 Duncan Booth duncan.booth@invalid.invalid wrote:

In this year's Christmas Raffle at work I won a 'party-in-a-box'
including USB fairy lights.

They sit boringly on all the time, so does anyone know if I can
toggle the power easily from a script? My work PC is running Win7.

 Not easily, no.  It's not really a USB device -- I'm betting it
 doesn't even enumerate.  It's just sucking power from the USB wires. 
 There's nothing to control.
Yes, I understand that, I was wondering whether the power could be toggled.
 
 Hmm. Can you control whether a particular port is on or off? (I have
 no idea what's possible with the underlying API, much less whether
 it's exposed.) It should in theory be possible - disable the
 appropriate USB port and the device loses power.
 
So far as I can tell Windows doesn't let you turn the ports on and off. I 
found some suggestion that by connecting it to a powered hub it may be 
possible to toggle the hub power on and off but that many hubs don't bother 
implementing the functionality.

Thanks anyway.
-- 
Duncan Booth http://kupuguy.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python, email temperature

2012-12-23 Thread Dave Angel
On 12/23/2012 08:46 AM, KarlE wrote:
 On Saturday, December 22, 2012 9:36:41 PM UTC+1, KarlE wrote:
 Hi!



 Im totally new to Python, and im using it on my Raspberry pi. I found a 
 program that sends an email, and one that checks the temperature of my CPU, 
 but i cant seem to combine the to into the funktion that i want, sending me 
 the CPU temp via Email.



 The two programs work very well on their own, but this doesnt work.



 this works: server.sendmail(fromaddr, toaddrs, msg)  

 but this doesnt: server.sendmail(fromaddr, toaddrs, cpu_temperature)



 despite the command print cputemp working in the same program. 



 When i run the program i get the error:  



 Traceback (most recent call last):

   File sendcpu.py, line 36, in module

 msg = cpu_temperature

 NameError: name 'cpu_temperature' is not defined



 Does anyone know why the program claims that cpu_temperature isnt defined, 
 when it is?



 Thanx!



 //Alexander
 Ok, im back with a little more understanding of python! I got the program 
 working, every time my Raspberry Pi reboots i get an Email containing 
 information about the boot and the CPU temperature.

 The issue now is that there seems to be a limitation to how long the message 
 string can be, about 32 letters. The code below works well, but when i add 
 more letters to the string ord and pass about 32 in size the email comes 
 through emptpy...

I don't know the email protocols that well, but I can tell you a Python
string isn't limited in size to any small value.  Maybe a few hundred
million characters, but i haven't tried beyond that.

i suspect the limit you're hitting is the limit of subject size in an
email protocol.  In particular, the 3rd argument to sendmail() needs to
have newlines in a particular format before you get to the body of the
email.  The body can be quite large, but you probably are required to
have the appropriate headers first.

When you send a short message, does it all come out as a subject line?

It would be good to look up the docs on smtplib, but if I had to just do
some blind testing, I'd try first adding a newline pair, changing the
line to something like:

ord = Subject: Pi Boot, CPU: \r\n + str(cpu_temperature) + 
WhateverOtherStuffYouWantedToTry






-- 

DaveA

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


Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-23 Thread prilisauer
Thanks to all your answers, I have read a lot about namespaces, but still 
there's something I do not understood. I have tried your example but as I 
expected:

line 13, in HandoverSQLCursor
curs.execute(SELECT * FROM lager)
AttributeError: 'builtin_function_or_method' object has no attribute 'execute'

I will try my best to write tomorrow a sample as detailed as possible.

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


Re: Python USB control on Windows 7?

2012-12-23 Thread Michael Torrie
On 12/23/2012 11:11 AM, Duncan Booth wrote:
 So far as I can tell Windows doesn't let you turn the ports on and off. I 
 found some suggestion that by connecting it to a powered hub it may be 
 possible to toggle the hub power on and off but that many hubs don't bother 
 implementing the functionality.
 
 Thanks anyway.

Or you might have more fun if you cut off the USB plug, and drive the
thing directly using an Arduino board.  You can use the USB serial port
on it to prgrammatically turn the thing on and off from your computer,
or a billion other possible things.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-23 Thread Peter Otten
prilisa...@googlemail.com wrote:

 Thanks to all your answers, I have read a lot about namespaces, but still
 there's something I do not understood. I have tried your example but as I
 expected:
 
 line 13, in HandoverSQLCursor
 curs.execute(SELECT * FROM lager)
 AttributeError: 'builtin_function_or_method' object has no attribute
 'execute'

You have assigned a built-in function to the curs variable. Example:

 curs = open
 curs.execute
Traceback (most recent call last):
  File stdin, line 1, in module
AttributeError: 'builtin_function_or_method' object has no attribute 
'execute'

You can find out the name of the actual function with

 print curs.__name__
open

PS: This question is only loosely related to your previous question. You 
should have started a new thread.




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


Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-23 Thread Roy Smith
In article mailman.1225.1356296379.29569.python-l...@python.org,
 prilisa...@googlemail.com wrote:

 Thanks to all your answers, I have read a lot about namespaces, but still 
 there's something I do not understood. I have tried your example but as I 
 expected:
 
 line 13, in HandoverSQLCursor
 curs.execute(SELECT * FROM lager)
 AttributeError: 'builtin_function_or_method' object has no attribute 
 'execute'
 
 I will try my best to write tomorrow a sample as detailed as possible.
 
 Good evening

Polishing up my crystal ball, I'm going to guess you're using one of the 
Python Database APIs (http://www.python.org/dev/peps/pep-0249/).  And 
that at some point, you tried to generate a cursor by doing:

   curs = connection.cursor

instead of 

   curs = connection.cursor()

This left you with curs being (a reference to) the cursor function 
itself, rather than what the function returns when it's called.

You own the oracle 20 minutes spent reading ESR's classic essay, How To 
Ask Questions The Smart Way (http://tinyurl.com/cabqnop).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-23 Thread prilisauer
Okay, I try to publish this sample, and yes it's not a working piece of code, 
but I try to draw my problem that way. As you will see, I load modules, 
create cursor,... in the main.py. In the lower section you see, that the 
modules should execute sqls. In case It could occur that two queries occur at 
the same time. PS: IT IS NOT A QUESTION ABOUT SQL, etc. I do not understand, 
how I could handle the part which is marked with Problemsection1 and 
Problemsection2

I hope really found the right wording. thank to all your help.


main.py
import HomeLog # LogHandler
import HomeSocketServer # Threaded TCP Socket Server
import HomeDatastore # SQLite DB
import HomeDaliServer # Connects to USB Device
import HomeScheduler # Advanced scheduler functions


# Attach Loghandler
Loghandler = HomeLog.Logging()
# Attach SocketServer
HomeSocketServer.HomeSocketServerStart()

# Attach Scheduler
HomeSched = HomeScheduler.HomeScheduler()
HomeSched.SchedulerStart()
HomeSched.SchedulerJobs()

# Attach Datastore
Datastore=HomeDatastore.HomeDBStore()
Datastore=Datastore.Startup()

#Attach Dali Driver
Dali=HomeDaliServer.Startup()
# This is a Sample that builds 2byte Cmd and transmits it on bus
PowerOnLamp1=Dali.send(0,0,1,80)

###
HomeDaliServer.py

def send (self,DaliAdress,RequestType,Request,RequestValue):
# Problemsection1:
# Here it's getting Interesting
# We're at the HomeDaliServer, and now I want to use QuerySqlite() in the file 
HomeDatastore.py

###
HomeScheduler.py
# Problemsection2:
# If new workerthread is started, Informations must be queried using 
QuerySlite() and also update data


###
HomeDatastore.py
def QuerySqlite():
#doing something here..
# returning Data

###

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


Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-23 Thread Rhodri James

On Sun, 23 Dec 2012 21:42:14 -, prilisa...@googlemail.com wrote:

Okay, I try to publish this sample, and yes it's not a working piece of  
code, but I try to draw my problem that way.


So instead of telling us what your problem is, you're going to give us an  
artist's impression of your code and leave us to guess?  Sorry but I'm not  
bored enough to try.


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


Re: Python, email temperature

2012-12-23 Thread Terry Reedy

On 12/23/2012 12:23 PM, Mitya Sirenef wrote:

On 12/23/2012 08:46 AM, KarlE wrote:

On Saturday, December 22, 2012 9:36:41 PM UTC+1, KarlE wrote:



from __future__ import division


Depending on the linux installed, you should be able to run 3.2 or 3.3 
instead of 2.7. Though there are still 2.x only modules, some things 
work better in 3.x (including default division).



 server.sendmail(fromaddr, toaddrs, ord)
 server.quit()

main()




I'm not sure if Raspberry Pi has it, but usually you want to
use the email module, as in example on this page:

http://docs.python.org/2/library/email-examples.html#email-examples


3.2+ have a separate .send_message method for email message objects.


I think what happens is that because your message starts
with 'Subject:', it's interpreted as subject header instead of
an email. You can try adding two newlines after Subject:,
that might help... but using email module is best if possible.


The 3.3 SMTP doc says that the fromaddr and toaddrs are only used by the 
transport layer and do not become part of the email message. The doc 
example has


msg = (From: %s\r\nTo: %s\r\n\r\n
   % (fromaddr, , .join(toaddrs)))

The body is appended after the double return. A subject line and any 
other standard headers would go before.


OT note: the PSF (Python Software Foundation) has bought a Raspberry PI 
and another ARM board to test Python on. I am happy to read that it 
seems to be working so far.


--
Terry Jan Reedy

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


Re: Parsing files in python

2012-12-23 Thread Chris Angelico
On Mon, Dec 24, 2012 at 4:19 AM, Kene Meniru kene.men...@illom.org wrote:
 Hello: I am writing a program that is made up of a collection of POV-Ray 
 macros. POV-Ray is available at povray.org. It is a ray-tracing program that 
 reads a scene description language (SDL) to create photo-realistic images. At 
 this time my program (for modeling building information) is so huge that I am 
 finding it difficult managing the macros and I am not even near completion.

I love POV-Ray! Great software, but the input language does at times
lack something, so I'm not surprised that you're wanting a pre-parser.

 possible user file content for parsing 
 // in the following the python interface program reads
 //+ the contents of the file other.file as if its content
 //+ were located at this point.
 include other.file

 //In the following the python interface makes snap_size a
 //+  global parameter
 declare snap_size = 10


 // In the following buildingLevel is a class that is
 //+  called and passed the parameters in parenthesis.
 buildingLevel(FirstLevel, 3000)

 // In the following snapOffset is a class that is
 //+  called and passed the parameters in parenthesis.
 snapOffset(Closet-S1_r1, Closet-S2_r3, 0,0,0)
 end of user file content

 It should also be possible to include comments using double-slashes, etc.

Hmm. That's a fairly complex file format you have there. I wonder if
it'd be possible to use an actual language parser for it - for
instance, to make this a real Python program. You'd have to use # for
a comment rather than //, and vector syntax may be a problem, but for
the rest, you should be able to do it all with just one extra line at
the top:

from povray_macros import *

You then write all your macros in a file called povray_macros.py and
they'll be conveniently available. For instance:

def buildingLevel(name, altitude):
print(... whatever POV-Ray code is needed ...)

Unfortunately POV-Ray doesn't seem to support reading from stdin, so
you can't simply pipe your program into the renderer. But you can do
it this way:

my_file_whatever_it_is.py temp.pov
povray +Itemp.pov

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


how to detect the character encoding in a web page ?

2012-12-23 Thread iMath
how to detect the character encoding  in a web page ?
such as this page 

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


Forking into the background (Linux)

2012-12-23 Thread Olive
My goal is to write a script that 1) write something to stdout; then 
fork into the background, closing the stdout (and stderr, stdin) pipe.


I have found this answer (forking - setsid - forking) 
http://stackoverflow.com/a/3356154


However the standard output of the child is still connected to the 
terminal. I would like that if we execute a subprocess.checkprocess on 
this program,  only I would like to see this is captured and that the 
program terminates when the parent exits.


#! /usr/bin/python2
import os,sys,time

print I would like to see this
pid = os.fork()
if (pid == 0): # The first child.
# os.chdir(/)
   os.setsid()
   # os.umask(0)
   pid2 = os.fork()
   if (pid2 == 0):  # Second child
 print I would like not see this
 time.sleep(5)
   else:
 sys.exit()#First child exists
else:   # Parent Code
  sys.exit()   # Parent exists
--
http://mail.python.org/mailman/listinfo/python-list


urllib.error.HTTPError: HTTP Error 403: Forbidden

2012-12-23 Thread iMath
 import urllib.request
 response = 
 urllib.request.urlopen('http://en.wikipedia.org/wiki/Internet_media_type')
Traceback (most recent call last):
  File pyshell#1, line 1, in module
response = 
urllib.request.urlopen('http://en.wikipedia.org/wiki/Internet_media_type')
  File C:\Python32\lib\urllib\request.py, line 138, in urlopen
return opener.open(url, data, timeout)
  File C:\Python32\lib\urllib\request.py, line 375, in open
response = meth(req, response)
  File C:\Python32\lib\urllib\request.py, line 487, in http_response
'http', request, response, code, msg, hdrs)
  File C:\Python32\lib\urllib\request.py, line 413, in error
return self._call_chain(*args)
  File C:\Python32\lib\urllib\request.py, line 347, in _call_chain
result = func(*args)
  File C:\Python32\lib\urllib\request.py, line 495, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 403: Forbidden


why this url generate error ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to detect the character encoding in a web page ?

2012-12-23 Thread Chris Angelico
On Mon, Dec 24, 2012 at 11:34 AM, iMath redstone-c...@163.com wrote:
 how to detect the character encoding  in a web page ?
 such as this page

 http://python.org/

You read part-way into the page, where you find this:

meta http-equiv=content-type content=text/html; charset=utf-8 /

That tells you that the character set is UTF-8.

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


Re: urllib.error.HTTPError: HTTP Error 403: Forbidden

2012-12-23 Thread Steven D'Aprano
On Sun, 23 Dec 2012 17:05:47 -0800, iMath wrote:

 import urllib.request
 response =
 urllib.request.urlopen('http://en.wikipedia.org/wiki/
Internet_media_type')
 Traceback (most recent call last):
   File pyshell#1, line 1, in module
 response =
 urllib.request.urlopen('http://en.wikipedia.org/wiki/
Internet_media_type')
[...]
 urllib.error.HTTPError: HTTP Error 403: Forbidden
 
 
 why this url generate error ?




Because you are in violation of Wikipedia's terms and services. Please do 
not try to screen-scrape Wikipedia. Instead, use their API for accessing 
pages.

http://en.wikipedia.org/wiki/Wikipedia:Creating_a_bot




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


Re: how to detect the character encoding in a web page ?

2012-12-23 Thread Hans Mulder
On 24/12/12 01:34:47, iMath wrote:
 how to detect the character encoding  in a web page ?

That depends on the site: different sites indicate
their encoding differently.

 such as this page:  http://python.org/

If you download that page and look at the HTML code, you'll find a line:

  meta http-equiv=content-type content=text/html; charset=utf-8 /

So it's encoded as utf-8.

Other sites declare their charset in the Content-Type HTTP header line.
And then there are sites relying on the default.  And sites that get
it wrong, and send data in a different encoding from what they declare.


Welcome to the real world,

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


Re: Parsing files in python

2012-12-23 Thread Terry Reedy

On 12/23/2012 12:19 PM, Kene Meniru wrote:

Hello: I am writing a program that is made up of a collection of
POV-Ray macros. POV-Ray is available at povray.org. It is a
ray-tracing program that reads a scene description language (SDL) to
create photo-realistic images. At this time my program (for modeling
building information) is so huge that I am finding it difficult
managing the macros and I am not even near completion.

I am hoping to move this program to python and am wondering the best
way to approach this.

I would like to model my program after LaTeX. Basically the user
writes a text file using certain key words and numbers and my python
program reads this file, calls the classes that will then work
together to calculate the information that is needed to create an
accurate model. The result of this calculation will be an output to
another text file in the appropriate format such as POV-Ray SDL,
OpenSCAD script, etc. This file output can then be rendered by the
corresponding program to produce the actual 3D model. The macros I
have now currently does this but like I said it is getting tedious
and most importantly the fun factor is losing its strength for me.

I have been advised to check out python-ply and I have come across
others. I have not really tried any yet and before I dive into any
one of them I was wondering what else I should know. The following is
a sample of what the text file that will be processed by this
proposed system will contain. I appreciate any pointers and
suggestions.


Mine is Don't do that. Seriously. What I understand is that you are 
proposing to design and write a parser for yet another Domain Specific 
Language -- that will require knowledge to use that is useless outside 
the specific domain. I expect that is will come to duplicate the basic 
facilities of existing languages. Users will want to be able to 
calculate, make conditional calculations and constructions, iterate*, 
and define functions (subroutines, macros). Why bother to reinvent all 
that? It often becomes a mess. (Or you will offer or people will want to 
mix Python with the dsl. That also can become a mess.)


Instead, write a pypovray package incorporating the POV macros, that can 
be imported into a python program. Write a tutorial for the specific 
parts of Python that users will need.


For instances, someone wants to place duplicate or parameterized models 
on a rectangular grid, along an arc, or even at random locations.



possible user file content for parsing  // in
the following the python interface program reads //+ the contents of
the file other.file as if its content //+ were located at this
point.


# this is a python comment. trivial difference from //

include other.file


import other.file  # with Python's variations
# or
exec(open('other.file'))  # but it is nearly always better to
# keep the separate namespace. What if a name in other.file
# is the same as used below?
import pypovray as ppr


//In the following the python interface makes snap_size a //+
global parameter

 declare snap_size = 10
snap_size = 10  # the extra word is just noise


// In the following buildingLevel is a class that is //+  called
and passed the parameters in parenthesis. buildingLevel(FirstLevel,
3000)

// In the following snapOffset is a class that is //+  called and
passed the parameters in parenthesis.



snapOffset(Closet-S1_r1, Closet-S2_r3, 0,0,0)


Already legal Python

# at the end of the file
ppr.run(args)

# Reads globals(), which python has nicely created for you, to create 
the master scene description and output whatever is needed for povray. 
It could be part of a template.py file you provide.


--
Terry Jan Reedy

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


Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-23 Thread Terry Reedy

On 12/23/2012 4:32 AM, prilisa...@googlemail.com wrote:

By the way, I think I have found the correct wording. for my
understood, the handover of objects to imported modules doesn't
work because, e.g. trying to hand-over an SQLite connection into a
imported module, can't work because the attributes are not
transfered.


I have not followed this thread, and do not know the context of your 
statement, or the code that did not work, but if you hand a Python 
object to an imported module, and something within the module can access 
the object, then all of its attributes are also accessible, the same as 
from the original module.


--
Terry Jan Reedy

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


Re: Forking into the background (Linux)

2012-12-23 Thread Hans Mulder
On 24/12/12 01:50:24, Olive wrote:
 My goal is to write a script that 1) write something to stdout; then
 fork into the background, closing the stdout (and stderr, stdin) pipe.
 
 I have found this answer (forking - setsid - forking)
 http://stackoverflow.com/a/3356154
 
 However the standard output of the child is still connected to the
 terminal. I would like that if we execute a subprocess.checkprocess on
 this program,  only I would like to see this is captured and that the
 program terminates when the parent exits.
 
 #! /usr/bin/python2
 import os,sys,time
 
 print I would like to see this
 pid = os.fork()
 if (pid == 0): # The first child.
 # os.chdir(/)
os.setsid()
# os.umask(0)
pid2 = os.fork()
if (pid2 == 0):  # Second child
  print I would like not see this
  time.sleep(5)
else:
  sys.exit()#First child exists
 else:   # Parent Code
   sys.exit()   # Parent exists

You could do this before forking:

sys.stdin.close()
sys.stdin = open('/dev/null', 'r')
sys.stdout.close()
sys.stdout = open('/dev/null', 'w')
sys.stderr.close()
sys.stderr = open('/dev/null', 'w')


You may want to look at the python-daemon module on Pypy, which appears
to do what you need, including some features you haven't asked for, yet.


Hope this helps,

-- HansM






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


Password hash

2012-12-23 Thread Robert Montgomery
I am writing a script that will send an email using an account I set up
in gmail. It is an smtp server using tls on port 587, and I would like
to use a password hash in the (python) script for login rather than
plain text. Is this do-able? Details please.

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


Re: how to detect the character encoding in a web page ?

2012-12-23 Thread iMath
在 2012年12月24日星期一UTC+8上午8时34分47秒,iMath写道:
 how to detect the character encoding  in a web page ?
 
 such as this page 
 
 
 
 http://python.org/

but how to let python do it for you ?

such as this page 

http://python.org/ 

how to  detect the character encoding in this web page by python ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to detect the character encoding in a web page ?

2012-12-23 Thread iMath
在 2012年12月24日星期一UTC+8上午8时34分47秒,iMath写道:
 how to detect the character encoding  in a web page ?
 
 such as this page 
 
 
 
 http://python.org/

but how to let python do it for you ? 

such as these 2 pages 

http://python.org/ 
http://msdn.microsoft.com/en-us/library/bb802962(v=office.12).aspx

how to  detect the character encoding in these 2 pages  by python ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to detect the character encoding in a web page ?

2012-12-23 Thread iMath
在 2012年12月24日星期一UTC+8上午8时34分47秒,iMath写道:
 how to detect the character encoding  in a web page ?
 
 such as this page 
 
 
 
 http://python.org/

but how to let python do it for you ? 

such as these 2 pages 

http://python.org/ 
http://msdn.microsoft.com/en-us/library/bb802962(v=office.12).aspx

how to  detect the character encoding in these 2 pages  by python ?
-- 
http://mail.python.org/mailman/listinfo/python-list


?????? compile python 3.3 with bz2 support

2012-12-23 Thread Isml
Thanks for your reply.According to your advice, I tried again, but still 
failed. Here is how I do this time:
1. I did not find package libbz2-dev in my source, so I still install it from 
source
2. I carefully checked the output of ./confiruge this time and find a warning 
: configure: WARNING: unrecognized options: --with-bz2?? so I used a wrong 
param?
3. I checked the build-in Python 2.4.3 which can successfully import bz2??and 
find a bz2.so in it's lib dir(/usr/lib/python2.4/lib-dynload/bz2.so)??I check 
the dependency of this file
[root@localhost lib-dynload]# ldd /usr/lib/python2.4/lib-dynload/bz2.so 
linux-gate.so.1 =  (0x002a)
libbz2.so.1 = /usr/lib/libbz2.so.1 (0x00336000)
libpthread.so.0 = /lib/libpthread.so.0 (0x00fa5000)
libc.so.6 = /lib/libc.so.6 (0x00128000)
/lib/ld-linux.so.2 (0x003e5000)
 
it seems that the redhat has already installed the libbz2.so. But I failed to 
find such a file
in my own compiled python 3.3 lib dir(/usr/local/lib/python3.3/lib-dynload/), 
strangely I see a file named _bz2.cpython-33m_failed.so, the name indicated 
that it is not a right file. I renamed it to bz2.so and tried again, finally 
get a
error:
 import bz2
Traceback (most recent call last):
  File stdin, line 1, in module
ImportError: dynamic module does not define init function (PyInit_bz2)

  

 

 --  --
  ??: Benjamin Kaplanbenjamin.kap...@case.edu;
 : 2012??12??23??(??) 0:06
 ??: Python Listpython-list@python.org; 
 
 : Re: compile python 3.3 with bz2 support

 

 

On Dec 21, 2012 1:31 AM, Isml 76069...@qq.com wrote:

 hi, everyone:
 I want to compile python 3.3 with bz2 support on RedHat 5.5 but fail to 
 do that. Here is how I do it:
 1. download bzip2 and compile it(make??make -f Makefile_libbz2_so??make 
 install)
 2.chang to python 3.3 source directory : ./configure 
 --with-bz2=/usr/local/include
 3. make
 4. make install
  
 after installation complete, I test it??
 [root@localhost Python-3.3.0]# python3 -c import bz2
 Traceback (most recent call last):
   File string, line 1, in module
   File /usr/local/lib/python3.3/bz2.py, line 21, in module
 from _bz2 import BZ2Compressor, BZ2Decompressor
 ImportError: No module named '_bz2'
 By the way, RedHat 5.5 has a built-in python 2.4.3. Would it be a problem?
  

 --
 
What is the output of configure? The last thing it does is list which modules 
are not going to be built. Is bz2 on the list? What does configure say when 
it's looking for bz2?-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Parsing files in python

2012-12-23 Thread Chris Angelico
On Mon, Dec 24, 2012 at 12:46 PM, Terry Reedy tjre...@udel.edu wrote:
 snapOffset(Closet-S1_r1, Closet-S2_r3, 0,0,0)


 Already legal Python


Not quite. This is the one part that *doesn't* work directly. In
POV-Ray, a vector eg x, y, z is used to represent points,
transformations, and sometimes colors. The closest Python equivalent
is the tuple, but that requires that the brackets be changed:

snapOffset(Closet-S1_r1, Closet-S2_r3, (0,0,0))

It would also require some smart footwork at the export end,
recognizing that a tuple needs to be output with angle brackets.

But other than that, yes, Python's a good choice for this. (I find it
amusing how I said yeah, good idea to make a DSL, I wonder if you can
capitalize on Python and you said don't make a DSL, maybe you can
capitalize on Python - opposite opening argument, same conclusion and
recommendation.)

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


Re: HTML - WEB FORM running PYTHON SCRIPT

2012-12-23 Thread llanitedave
I'll second this.  Javascript is pretty comparable to Python in ease of 
learning, so that should be no obstacle.  As for keeping the code from being 
accessible, you can put the javascript in a separate file that's called from 
the guest's web page, but that's far from a foolproof method.  If you want the 
guest browser to do the calculation, there's no realistic way to keep the 
calculation code off of it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-23 Thread Thomas Bach
Hi there,

On Sun, Dec 23, 2012 at 01:42:14PM -0800, prilisa...@googlemail.com wrote:
 […] In the lower section you see, that the modules should execute
 sqls. In case It could occur that two queries occur at the same
 time.  PS: IT IS NOT A QUESTION ABOUT SQL, etc. I do not understand,
 how I could handle the part which is marked with Problemsection1 and
 Problemsection2

I actually do not understand the problem you are stating. But, did you
have a look at SQLAlchemy? If you are coping a lot with SQL it really
makes your life much easier and they also provide the necessary
mechanisms for threading.

 import HomeLog # LogHandler

Modules should be written all lower-case separated by underscores.

 # Attach Loghandler
 Loghandler = HomeLog.Logging()

Have a look at the logging module and tutorial. I don't know what is
in HomeLog.Logging, but this doesn't seem right. 

Variables defined at module level should be written all upper-case.

 # Attach SocketServer
 HomeSocketServer.HomeSocketServerStart()
 
 # Attach Scheduler
 HomeSched = HomeScheduler.HomeScheduler()
 […]
 # This is a Sample that builds 2byte Cmd and transmits it on bus
 PowerOnLamp1=Dali.send(0,0,1,80)

You do all this on the module level? These things should go into
functions with proper names or at least into a 

if __name__ == '__main__':
pass


 ###
 HomeDaliServer.py
 
 def send (self,DaliAdress,RequestType,Request,RequestValue):
 # Problemsection1:
 # Here it's getting Interesting
 # We're at the HomeDaliServer, and now I want to use QuerySqlite()
 in the file HomeDatastore.py

So, where's the problem?

# make sure not to introduce cyclic dependence here!
import home_data_store

def send (connection,DaliAdress,RequestType,Request,RequestValue):
results = home_data_store.query_sqlite(connection, …)
return results


 ###
 HomeScheduler.py
 # Problemsection2:
 # If new workerthread is started, Informations must be queried using
 QuerySlite() and also update data

So, here's a first sketch (untested):

def query():
data = do_something()
return data

def update(data):
do_something_with(data)


 HomeDatastore.py
 def QuerySqlite():
 #doing something here..
 # returning Data

Have you read the Python tutorial by the way?

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


Re: [Help] [Newbie] Require help migrating from Perl to Python 2.7 (namespaces)

2012-12-23 Thread Dave Angel
On 12/23/2012 04:42 PM, prilisa...@googlemail.com wrote:
 Okay, I try to publish this sample, and yes it's not a working piece of code, 
 but I try to draw my problem that way. As you will see, I load modules, 
 create cursor,... in the main.py. In the lower section you see, that the 
 modules should execute sqls. In case It could occur that two queries occur at 
 the same time. PS: IT IS NOT A QUESTION ABOUT SQL, etc. I do not understand, 
 how I could handle the part which is marked with Problemsection1 and 
 Problemsection2
You're miles from being ready to worry about the same time.  Don't
start threading till you can get a simple multi-module program understood.
 I hope really found the right wording. thank to all your help.


 main.py

For some reason you capitalize all those filenames, so you're stuck with
unpythonic module names.  If you want your code readable, use lowercase
for module name, and Capitalized for class name.

 import HomeLog # LogHandler
 import HomeSocketServer # Threaded TCP Socket Server
 import HomeDatastore # SQLite DB
 import HomeDaliServer # Connects to USB Device
 import HomeScheduler # Advanced scheduler functions


 # Attach Loghandler
 Loghandler = HomeLog.Logging()
 # Attach SocketServer
 HomeSocketServer.HomeSocketServerStart()

 # Attach Scheduler
 HomeSched = HomeScheduler.HomeScheduler()
 HomeSched.SchedulerStart()
 HomeSched.SchedulerJobs()

 # Attach Datastore
 Datastore=HomeDatastore.HomeDBStore()
 Datastore=Datastore.Startup()

 #Attach Dali Driver
 Dali=HomeDaliServer.Startup()
 # This is a Sample that builds 2byte Cmd and transmits it on bus
 PowerOnLamp1=Dali.send(0,0,1,80)

 ###
 HomeDaliServer.py
import HomeDatastore
 
 def send (self,DaliAdress,RequestType,Request,RequestValue):
Nobody's going to be able to understand your code if you persist in
using self in unpythonic ways.  It's used as the first argument of a
class method. Period.
 # Problemsection1:
 # Here it's getting Interesting
 # We're at the HomeDaliServer, and now I want to use QuerySqlite() in the 
 file HomeDatastore.py
So call it:
   firstarg = whatever * RequestType
   secondarg = something different + RequestValue
   result = HomeDatastore.QuerySqlite(firstarg, secondarg)
 ###
 HomeScheduler.py
Where are your import statements?  No module automatically sees imports
that were done elsewhere.  Import what you need in a module.
 # Problemsection2:
 # If new workerthread is started, Informations must be queried using 
 QuerySlite() and also update data
I don't see any 'update data' function anywhere, but if you want to call
QuerySqlite, you need to call it:
  thisresult = HomeDatastore.QuerySqlite(him, her, theother)

 ###
 HomeDatastore.py
 def QuerySqlite():
You presumably mean
  def QuerySqlite(firstparam, secondparam):

since a function with no arguments is going to be stuck trying to use
globals, and that's not a good habit to get into.
 #doing something here..
#doing something with those parameters, and only those parameters
 # returning Data

 ###



-- 

DaveA

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


?????? compile python 3.3 with bz2 support

2012-12-23 Thread Isml
Finally I worked it out. I write it down Here to people who meet the same 
problem like me.
 1. Install bzip2 from source is OK
 2. There is no need to add --with-bz2 to ./configure, because it is not a 
valid param. python makefile will search the bz2 itself, if it find the bz2 
lib, it will automatically compile this module. see setup.py line 1373. So the 
./configure outputs the warning : configure: WARNING: unrecognized options: 
--with-bz2
 3. The reason why I failed before is that I did not correctly compile the 
bz2.so, the filename _bz2.cpython-33m_failed.so has indicated that fact. And 
the reason why I faild to compile bz2.so is strangely the RedHat SELinux. So 
the only thing I then do is disable it (setenforce 0), after that, everything 
is OK.
  
 Thanks for everyone.
  

 

 --  --
  ??: Isml76069...@qq.com;
 : 2012??12??24??(??) 11:21
 ??: Benjamin Kaplanbenjamin.kap...@case.edu; Python 
Listpython-list@python.org; 
 
 : ?? compile python 3.3 with bz2 support

 

 Thanks for your reply.According to your advice, I tried again, but still 
failed. Here is how I do this time:
1. I did not find package libbz2-dev in my source, so I still install it from 
source
2. I carefully checked the output of ./confiruge this time and find a warning 
: configure: WARNING: unrecognized options: --with-bz2?? so I used a wrong 
param?
3. I checked the build-in Python 2.4.3 which can successfully import bz2??and 
find a bz2.so in it's lib dir(/usr/lib/python2.4/lib-dynload/bz2.so)??I check 
the dependency of this file
[root@localhost lib-dynload]# ldd /usr/lib/python2.4/lib-dynload/bz2.so 
linux-gate.so.1 =  (0x002a)
libbz2.so.1 = /usr/lib/libbz2.so.1 (0x00336000)
libpthread.so.0 = /lib/libpthread.so.0 (0x00fa5000)
libc.so.6 = /lib/libc.so.6 (0x00128000)
/lib/ld-linux.so.2 (0x003e5000)
 
it seems that the redhat has already installed the libbz2.so. But I failed to 
find such a file
in my own compiled python 3.3 lib dir(/usr/local/lib/python3.3/lib-dynload/), 
strangely I see a file named _bz2.cpython-33m_failed.so, the name indicated 
that it is not a right file. I renamed it to bz2.so and tried again, finally 
get a
error:
 import bz2
Traceback (most recent call last):
  File stdin, line 1, in module
ImportError: dynamic module does not define init function (PyInit_bz2)

  

 

 --  --
  ??: Benjamin Kaplanbenjamin.kap...@case.edu;
 : 2012??12??23??(??) 0:06
 ??: Python Listpython-list@python.org; 
 
 : Re: compile python 3.3 with bz2 support

 

 

On Dec 21, 2012 1:31 AM, Isml 76069...@qq.com wrote:

 hi, everyone:
 I want to compile python 3.3 with bz2 support on RedHat 5.5 but fail to 
 do that. Here is how I do it:
 1. download bzip2 and compile it(make??make -f Makefile_libbz2_so??make 
 install)
 2.chang to python 3.3 source directory : ./configure 
 --with-bz2=/usr/local/include
 3. make
 4. make install
  
 after installation complete, I test it??
 [root@localhost Python-3.3.0]# python3 -c import bz2
 Traceback (most recent call last):
   File string, line 1, in module
   File /usr/local/lib/python3.3/bz2.py, line 21, in module
 from _bz2 import BZ2Compressor, BZ2Decompressor
 ImportError: No module named '_bz2'
 By the way, RedHat 5.5 has a built-in python 2.4.3. Would it be a problem?
  

 --
 
What is the output of configure? The last thing it does is list which modules 
are not going to be built. Is bz2 on the list? What does configure say when 
it's looking for bz2?-- 
http://mail.python.org/mailman/listinfo/python-list


Making a Unix daemon process (was: Forking into the background (Linux))

2012-12-23 Thread Ben Finney
Hans Mulder han...@xs4all.nl writes:

 On 24/12/12 01:50:24, Olive wrote:
  My goal is to write a script that 1) write something to stdout; then
  fork into the background, closing the stdout (and stderr, stdin) pipe.
  
  I have found this answer (forking - setsid - forking)
  http://stackoverflow.com/a/3356154

You're following a path that leads to the desire for a “daemon”
URL:http://stackoverflow.com/questions/473620/how-do-you-create-a-daemon-in-python/688448#688448.

 You may want to look at the python-daemon module on Pypy, which
 appears to do what you need, including some features you haven't asked
 for, yet.

It's even better when you look at it on PyPI
URL:http://pypi.python.org/pypi/python-daemon/ (note that PyPy is a
Python implementation, PyPI is an index of Python packages).

The discussion forum for ‘python-daemon’ development is at
URL:http://lists.alioth.debian.org/mailman/listinfo/python-daemon-devel.

-- 
 \ “Faith may be defined briefly as an illogical belief in the |
  `\  occurrence of the improbable.” —Henry L. Mencken |
_o__)  |
Ben Finney

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


[issue1927] raw_input behavior incorrect if readline not enabled

2012-12-23 Thread Daniel Gonzalez

Daniel Gonzalez added the comment:

Please see this stackoverflow thread where more information is given about this 
issue:

http://stackoverflow.com/questions/14009714/strange-redirection-effect-with-raw-input

--
nosy: +Daniel.Gonzalez

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



[issue14373] C implementation of functools.lru_cache

2012-12-23 Thread Stefan Behnel

Stefan Behnel added the comment:

Just for the record, I've compiled Raymond's roadmap version in Cython (with 
only slight changes to make 'self.maxsize' a Py_ssize_t and using an external 
.pxd for typing) and ran Serhiy's benchmark over it (Ubuntu 12.10, 64bit). This 
is what I get in Py3.4:

 0.022  untyped_cy(i)
 0.023  untyped_cy(spam, i)
 0.024  untyped_cy(spam, spam, i)
 0.106  untyped_cy(a=i)
 0.133  untyped_cy(a=spam, b=i)
 0.152  untyped_cy(a=spam, b=spam, c=i)
 0.033  typed_cy(i)
 0.038  typed_cy(spam, i)
 0.039  typed_cy(spam, spam, i)
 0.129  typed_cy(a=i)
 0.168  typed_cy(a=spam, b=i)
 0.183  typed_cy(a=spam, b=spam, c=i)

 0.143  untyped_py(i)
 0.234  untyped_py(spam, i)
 0.247  untyped_py(spam, spam, i)
 0.368  untyped_py(a=i)
 0.406  untyped_py(a=spam, b=i)
 0.425  untyped_py(a=spam, b=spam, c=i)
 0.447  typed_py(i)
 0.469  typed_py(spam, i)
 0.480  typed_py(spam, spam, i)
 0.745  typed_py(a=i)
 0.783  typed_py(a=spam, b=i)
 0.819  typed_py(a=spam, b=spam, c=i)

Looking at the factors, that's about the same speedup that the dedicated hand 
tuned C implementation presented according to Serhiy's own runs (he reported 
10-25x). Makes me wonder why we should have two entirely separate 
implementations for this.

Here's the lru_cache_class.pxd file I used:


cimport cython

cdef make_key(tuple args, dict kwds, bint typed, tuple kwd_mark)

@cython.final
@cython.internal
cdef class c_lru_cache:
cdef dict cache
cdef Py_ssize_t hits
cdef Py_ssize_t misses
cdef Py_ssize_t maxsize
cdef bint typed
cdef object user_function
cdef object cache_info_type
cdef tuple kwd_mark
cdef list root


--
nosy: +scoder

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



[issue16743] mmap accepts files 1 GB, but processes only 1 GB

2012-12-23 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Terry, what makes you think this is a feature request? This is a bug, quite 
simply.

--
nosy: +pitrou
versions: +Python 2.7, Python 3.2, Python 3.3

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



[issue16045] add more unit tests for built-in int()

2012-12-23 Thread Anton Kasyanov

Anton Kasyanov added the comment:

looks good to me

--
nosy: +asvetlov, mindmaster

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



[issue13178] Need tests for Unicode handling in install_distinfo and install_data

2012-12-23 Thread Andrew Svetlov

Changes by Andrew Svetlov andrew.svet...@gmail.com:


--
nosy: +asvetlov

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



[issue9856] Change object.__format__(s) where s is non-empty to a TypeError

2012-12-23 Thread Viktor Ershov

Viktor Ershov added the comment:

As I can see this is already implemented in 3.4

--
nosy: +asvetlov, krinart

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



[issue16753] #include ctype.h broken on FreeBSD 9.1-RELEASE

2012-12-23 Thread Stefan Krah

New submission from Stefan Krah:

This is strictly a buildbot issue. #include ctype.h seems broken on

http://buildbot.python.org/all/builders/AMD64%20FreeBSD%209.0%20dtrace%203.3/builds/248/steps/compile/logs/stdio



In file included from /usr/include/ctype.h:83,
 from 
/usr/home/buildbot/python/3.3.koobs-freebsd/build/Modules/_decimal/libmpdec/io.c:33:
/usr/include/xlocale/_ctype.h:56:38: error: operator '!' has no right operand


Also note that the buildbot software reports success (i.e. the compile step is 
green) despite the error.

--
keywords: buildbot
messages: 177971
nosy: koobs, skrah
priority: normal
severity: normal
status: open
title: #include ctype.h broken on FreeBSD 9.1-RELEASE
versions: Python 3.3, Python 3.4

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



[issue11379] Remove lightweight from minidom description

2012-12-23 Thread Stefan Behnel

Stefan Behnel added the comment:

Any news on this?

--

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



[issue16045] add more unit tests for built-in int()

2012-12-23 Thread Roundup Robot

Roundup Robot added the comment:

New changeset c502a2dc0345 by Andrew Svetlov in branch '2.7':
Issue #16045: add more unit tests for built-in int()
http://hg.python.org/cpython/rev/c502a2dc0345

New changeset a90d7003966e by Andrew Svetlov in branch '3.3':
Issue #16045: add more unit tests for built-in int()
http://hg.python.org/cpython/rev/a90d7003966e

New changeset ec7146b18274 by Andrew Svetlov in branch 'default':
Issue #16045: add more unit tests for built-in int()
http://hg.python.org/cpython/rev/ec7146b18274

--
nosy: +python-dev

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



[issue16045] add more unit tests for built-in int()

2012-12-23 Thread Andrew Svetlov

Andrew Svetlov added the comment:

Committed. Thanks.

--

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



[issue16045] add more unit tests for built-in int()

2012-12-23 Thread Andrew Svetlov

Changes by Andrew Svetlov andrew.svet...@gmail.com:


--
resolution:  - fixed
stage: patch review - committed/rejected
status: open - closed

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



[issue16745] Hide symbols in _decimal.so

2012-12-23 Thread Stefan Krah

Changes by Stefan Krah stefan-use...@bytereef.org:


--
resolution:  - fixed
stage:  - committed/rejected
status: open - closed

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



[issue16443] Add docstrings to regular expression match objects

2012-12-23 Thread Anton Kasyanov

Anton Kasyanov added the comment:

Created a patch with docstrings for match objects. Also added empty lines in 
pattern object docstrings according to 
http://www.python.org/dev/peps/pep-0007/#id7

--
keywords: +patch
nosy: +a.kasyanov, asvetlov
versions:  -Python 2.7
Added file: http://bugs.python.org/file28403/issue-16443.diff

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



[issue14373] C implementation of functools.lru_cache

2012-12-23 Thread Stefan Krah

Stefan Krah added the comment:

Hmm. Judging by the numbers for the Python version, my machine appears
to be slower than Stefan (Behnel)'s machine, and yet the C version is
much faster here than the posted Cython numbers.

If I adjust the results for the machine differences, the C version
would appear to be 2.5x faster than the Cython version.

--
nosy: +skrah

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



[issue9856] Change object.__format__(s) where s is non-empty to a TypeError

2012-12-23 Thread Roundup Robot

Roundup Robot added the comment:

New changeset d91c14788729 by Andrew Svetlov in branch 'default':
Issue #9856: Replace deprecation warinigs to raising TypeError in 
object.__format__
http://hg.python.org/cpython/rev/d91c14788729

--

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



[issue15302] Use argparse instead of getopt in test.regrtest

2012-12-23 Thread Anton Kasyanov

Anton Kasyanov added the comment:

I've looked through the second patch and I'm not sure about how argparse usage 
was implemented here - parse_args() result is being converted to getopt-style 
list of (option, value) pairs.
 
Is there any sense in using argparse this way?

--
nosy: +a.kasyanov, asvetlov

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



[issue16754] Incorrect shared library extension on linux

2012-12-23 Thread Sandro Mani

New submission from Sandro Mani:

I'm using Python3 as available in Fedora rawhide 
(python3-3.3.0-2.fc19.x86_64).

Attempting to build a project using python3/distutils, I noticed that 
find_library_file would not find any library at all. Some investigation 
showed that this was due to the fact that libraries were searched with 
the .cpython-33m.so extension. Even more investigation showed that the 
library extension was read being overridden by the one defined in the 
/usr/lib64/python3.3/config-3.3m/Makefile shipped by python3-libs. See 
below for the detailed analysis. The python-versioned extension 
obviously makes no sense for regular shared objects which are not python 
binary modules, so this is clearly wrong. As a workaround I patched 
sysconfig.py to comment out customize_compiler::235 
(compiler.shared_lib_extension = 
so_ext, see below), recompiled python (all tests still pass), and things seem 
to work.


Detailed analysis:

setup.py:
def _find_library_file(self, library):
 return self.compiler.find_library_file(self.compiler.library_dirs, 
library)

---
In function 
/usr/lib64/python3.3/distutils/unixcompiler.py at find_library_file::266:
shared_f = self.library_filename(lib, lib_type='shared')

In function 
/usr/lib64/python3.3/distutils/ccompiler.py at library_filename::882:
ext = getattr(self, lib_type + _lib_extension)

- Where does shared_lib_extension get defined?
* At /usr/lib64/python3.3/distutils/ccompiler.py::66
shared_lib_extension = None   - default for abstract class
* At /usr/lib64/python3.3/distutils/unixcompiler.py::77
shared_lib_extension = .so  - this is the correct value
* In function 
/usr/lib64/python3.3/distutils/sysconfig.py at customize_compiler::235
by /usr/lib64/python3.3/distutils/sysconfig.py at customize_compiler::235
 compiler.shared_lib_extension = so_ext
by /usr/lib64/python3.3/distutils/sysconfig.py at customize_compiler::194
(cc, cxx, opt, cflags, ccshared, ldshared, so_ext, ar, ar_flags) = \
 get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
 'CCSHARED', 'LDSHARED', 'SO', 'AR', 'ARFLAGS'))
by /usr/lib64/python3.3/distutils/sysconfig.py at get_config_vars::530
526 global _config_vars
527 if _config_vars is None:
528 func = globals().get(_init_ + os.name)  # - os.name = posix
529 if func:
530 func()  # - _init_posix, populates _config_vars
by /usr/lib64/python3.3/distutils/sysconfig.py at _init_posix::439
435 g = {}
436 # load the installed Makefile:
437 try:
438 filename = get_makefile_filename()  # 
/usr/lib64/python3.3/config-3.3m/Makefile
439 parse_makefile(filename, g)
...
476 global _config_vars
477 _config_vars = g  # - _config_vars[SO] = .cpython-33m.so
by /usr/lib64/python3.3/config-3.3m/Makefile::122
SO= .cpython-33m.so

--
assignee: eric.araujo
components: Distutils
messages: 177979
nosy: eric.araujo, smani, tarek
priority: normal
severity: normal
status: open
title: Incorrect shared library extension on linux
type: behavior
versions: Python 3.3

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



[issue14373] C implementation of functools.lru_cache

2012-12-23 Thread Stefan Krah

Stefan Krah added the comment:

I've managed to build the Cython version now. It's in fact between 4 and 6
times slower here than the C version.

--

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



[issue9856] Change object.__format__(s) where s is non-empty to a TypeError

2012-12-23 Thread Andrew Svetlov

Andrew Svetlov added the comment:

Committed. Thanks.

--
resolution:  - fixed
stage:  - committed/rejected
status: open - closed

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



[issue879399] socket line buffering

2012-12-23 Thread oleg chubin

oleg chubin added the comment:

I just have updated patch for current version of code. It looks good for me.

--
nosy: +0lejka, asvetlov
Added file: http://bugs.python.org/file28404/_fileobject23122012.diff

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



[issue9856] Change object.__format__(s) where s is non-empty to a TypeError

2012-12-23 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 2f6ec67636b8 by Andrew Svetlov in branch 'default':
Add NEWS and docs for #9856
http://hg.python.org/cpython/rev/2f6ec67636b8

--

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



[issue9856] Change object.__format__(s) where s is non-empty to a TypeError

2012-12-23 Thread Andrew Svetlov

Andrew Svetlov added the comment:

Updated NEWS and docs

--

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



[issue16684] Unicode property value abbreviated names and long names

2012-12-23 Thread Pander

Pander added the comment:

Attached is the requested proof-of-concept script.

--
Added file: 
http://bugs.python.org/file28405/create-unicodedata-dicts-prop-value-alias-20121223.py

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



[issue879399] socket line buffering

2012-12-23 Thread Andrew Svetlov

Andrew Svetlov added the comment:

LGTM.
Kristján, would you like to commit?

--

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



[issue16753] #include ctype.h broken on FreeBSD 9.1-RELEASE

2012-12-23 Thread koobs

koobs added the comment:

This was noted by Dmitry Sivachenko during tests of my python33 port for 
FreeBSD, with the following commits going to HEAD (CURRENT) and RELENG_9 
(9-STABLE) respectively:

http://svnweb.freebsd.org/base?view=revisionrevision=243032
http://svnweb.freebsd.org/base?view=revisionrevision=243331

If you need me to get any more info let me know

--

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



[issue16753] #include ctype.h broken on FreeBSD 9.1-RELEASE

2012-12-23 Thread Stefan Krah

Stefan Krah added the comment:

Thanks, it's really a FreeBSD issue then. I was wondering how this
could go undetected in a production release. The reason is probably
that __GNUC_STDC_INLINE__ (which libmpdec uses) is quite rare.

--
resolution:  - invalid
stage:  - committed/rejected
status: open - closed

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



[issue16753] #include ctype.h broken on FreeBSD 9.1-RELEASE

2012-12-23 Thread Stefan Krah

Stefan Krah added the comment:

On second thought, gcc defines __GNUC_STDC_INLINE__ to 1, so probably
libmpdec should do the same.

--

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



[issue16753] #include ctype.h broken on FreeBSD 9.1-RELEASE

2012-12-23 Thread Roundup Robot

Roundup Robot added the comment:

New changeset f05d29353f02 by Stefan Krah in branch '3.3':
Issue #16753: Define __GNUC_STDC_INLINE__ to an integer (same as gcc).
http://hg.python.org/cpython/rev/f05d29353f02

--
nosy: +python-dev

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



[issue16755] Distutils2 incorrectly works with unicode package names

2012-12-23 Thread Volodymyr Hotsyk

New submission from Volodymyr Hotsyk:

While testing #13178, found that Distutils2 incorrectly works with the package 
names containing unicode symbols. Please check test attached.

--
assignee: eric.araujo
components: Distutils2
files: unicode_test.diff
keywords: patch
messages: 177991
nosy: alexis, asvetlov, eric.araujo, hotsyk, tarek
priority: normal
severity: normal
status: open
title: Distutils2 incorrectly works with unicode package names
type: enhancement
versions: Python 3.3
Added file: http://bugs.python.org/file28406/unicode_test.diff

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



[issue9856] Change object.__format__(s) where s is non-empty to a TypeError

2012-12-23 Thread Eric V. Smith

Eric V. Smith added the comment:

The more I think about this, the more overly restrictive I realize it is. If 
the type of the object really is object, then it can use string formatting. 
It's only for non-objects that I want to add the error.

I'll re-open it and give it some more thought.

--
resolution: fixed - 
stage: committed/rejected - 
status: closed - open

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



[issue14373] C implementation of functools.lru_cache

2012-12-23 Thread Stefan Behnel

Stefan Behnel added the comment:

Yep, I basically didn't do any optimisation, it's the plain Python code 
compiled, just with the class being converted into an extension type.

--

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



[issue9856] Change object.__format__(s) where s is non-empty to a TypeError

2012-12-23 Thread Andrew Svetlov

Andrew Svetlov added the comment:

Ok

--

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



[issue16756] buggy assignment to items of a list created by a * operator

2012-12-23 Thread jp

New submission from jp:

The following code: 

li = [[1,0]]*5
a = [[1,10], [2,20], [3,30]]
for line in a:
li[line[0]][0] = 2
print(li)

prints [[2,0],[2,0],[2,0],[2,0],[2,0]], but should print 
[[1,0],[2,0],[2,0],[2,0],[1,0]]. 

The output is correct if you, instead of using li = [[1,0]]*5, initialize the 
array as follows:

li = []
for i in range(5): li.append([1,0])

--
components: Interpreter Core
messages: 177995
nosy: jenda.pet...@gmail.com
priority: normal
severity: normal
status: open
title: buggy assignment to items of a list created by a * operator
versions: Python 3.3

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



[issue16756] buggy assignment to items of a list created by a * operator

2012-12-23 Thread Christian Heimes

Christian Heimes added the comment:

The outcome is correct. You have fallen for a common beginners gotcha:

http://www.enricozini.org/2011/tips/python-list-gotcha

--
nosy: +christian.heimes
resolution:  - invalid
status: open - closed

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



[issue9584] Allow curly brace expansion

2012-12-23 Thread Janus Troelsen

Changes by Janus Troelsen ysang...@gmail.com:


--
nosy: +ysangkok

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



[issue16757] Faster _PyUnicode_FindMaxChar()

2012-12-23 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

The proposed patch optimizes _PyUnicode_FindMaxChar(). This affects string 
formatting of long patterns (speedup to 15-25% for classic formatting and 5-8% 
for new style formatting).

--
components: Interpreter Core, Unicode
files: unicode_findmaxchar.patch
keywords: patch
messages: 177997
nosy: ezio.melotti, haypo, serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Faster _PyUnicode_FindMaxChar()
type: performance
versions: Python 3.4
Added file: http://bugs.python.org/file28407/unicode_findmaxchar.patch

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



[issue16757] Faster _PyUnicode_FindMaxChar()

2012-12-23 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


Added file: http://bugs.python.org/file28408/format_bench.sh

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



[issue15701] AttributeError from HTTPError when using digest auth

2012-12-23 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 3046bfea59f3 by Senthil Kumaran in branch '2.7':
Fix Issue15701 - HTTPError info method call raises AttributeError. Fix that to 
return headers correctly
http://hg.python.org/cpython/rev/3046bfea59f3

New changeset 919ebf74bfdb by Senthil Kumaran in branch '3.2':
Fix Issue15701 - HTTPError info method call raises AttributeError. Fix that to 
return headers correctly
http://hg.python.org/cpython/rev/919ebf74bfdb

New changeset a15109398294 by Senthil Kumaran in branch '3.3':
merge from 3.2
http://hg.python.org/cpython/rev/a15109398294

--

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



[issue15701] AttributeError from HTTPError when using digest auth

2012-12-23 Thread Senthil Kumaran

Senthil Kumaran added the comment:

Okay. this is fixed in all versions of python. Sorry for the delay.

--
resolution:  - fixed
status: open - closed

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



[issue16758] SubprocessStartupError

2012-12-23 Thread Lieutenant Commander Mohd Nazri Mohd Nasir RMN

New submission from Lieutenant Commander Mohd Nazri Mohd Nasir RMN:

I always get this message lately, when I try to run python in IDLE.

--
components: IDLE
files: SubprocessStartupErrorMessage.jpg
messages: 178000
nosy: Lieutenant.Commander.Mohd.Nazri.Mohd.Nasir.RMN
priority: normal
severity: normal
status: open
title: SubprocessStartupError
type: performance
versions: Python 2.7
Added file: http://bugs.python.org/file28409/SubprocessStartupErrorMessage.jpg

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



[issue16443] Add docstrings to regular expression match objects

2012-12-23 Thread Roundup Robot

Roundup Robot added the comment:

New changeset e4f1b3565509 by Andrew Svetlov in branch '3.2':
Issue #16443: Add docstrings to regular expression match objects.
http://hg.python.org/cpython/rev/e4f1b3565509

New changeset 64e050c2d010 by Andrew Svetlov in branch '3.3':
Issue #16443: Add docstrings to regular expression match objects.
http://hg.python.org/cpython/rev/64e050c2d010

New changeset e3d0417d8266 by Andrew Svetlov in branch 'default':
Issue #16443: Add docstrings to regular expression match objects.
http://hg.python.org/cpython/rev/e3d0417d8266

--
nosy: +python-dev

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



[issue16443] Add docstrings to regular expression match objects

2012-12-23 Thread Roundup Robot

Roundup Robot added the comment:

New changeset c390dc999fcc by Andrew Svetlov in branch '2.7':
Issue #16443: Add docstrings to regular expression match objects.
http://hg.python.org/cpython/rev/c390dc999fcc

--

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



[issue16741] `int()`, `float()`, etc think python strings are null-terminated

2012-12-23 Thread Matthew Barnett

Matthew Barnett added the comment:

It occurred to me that the truncation of the string when building the error 
message could cause a UnicodeDecodeError:

 int(1.ljust(199) + \u0100)
Traceback (most recent call last):
  File pyshell#0, line 1, in module
int(1.ljust(199) + \u0100)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc4 in position 199: 
unexpected end of data

This is because it's truncating a UTF-8 string, and the truncation is in the 
middle of a multi-byte sequence.

--

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



[issue16443] Add docstrings to regular expression match objects

2012-12-23 Thread Andrew Svetlov

Andrew Svetlov added the comment:

Pushed. Thank you, Anton!

--
resolution:  - fixed
stage: needs patch - committed/rejected
status: open - closed
versions: +Python 2.7

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



[issue16689] stdout stderr redirection mess

2012-12-23 Thread anatoly techtonik

anatoly techtonik added the comment:

Can Python detect when output file descriptor for both stderr and stdout 
streams is the same and use the single buffer itself?

--
status: closed - open

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



[issue15302] Use argparse instead of getopt in test.regrtest

2012-12-23 Thread Chris Jerdonek

Chris Jerdonek added the comment:

The reason in part is because of the lack of unit tests of regrtest (as 
commenters above have noted).  By preserving the getopt interface, we can keep 
almost all of the untested code as is.

You should view the patch as a first step in refactoring to use argparse.  We 
can remove the conversion code and the main for loop in later steps.

Note to committers: I was meaning to rename regrlib.py when I was working on 
this.  Until regrtest-related code is in its own subpackage, I think the file 
name should begin with regrtest -- perhaps regrtester.py or regrtestlib.py.

--

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



[issue15303] Minor revision to the BaseWidget._setup method in Tkinter

2012-12-23 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Here is a patch against 3.4 which contains proposed OP change and a lot of 
similar changes in different places. I'm not sure that this should be 
considered as a bug fix and not as an enhancement.

Drew, as a workaround you can implement __bool__() method which returns True 
for your widget. Or even better, do not make your container sequence-like.

--
keywords: +patch
nosy: +serhiy.storchaka
stage: needs patch - patch review
versions: +Python 3.4 -Python 2.7
Added file: http://bugs.python.org/file28410/tkinter_widget_is_none.patch

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



[issue16743] mmap accepts files 1 GB, but processes only 1 GB

2012-12-23 Thread Terry J. Reedy

Terry J. Reedy added the comment:

It is a report of behavior that lacks a specific request for change (that I can 
see). The implied code-change request could break working code. We don't 
usually do that. What do you think should be done?

--

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



[issue16689] stdout stderr redirection mess

2012-12-23 Thread Łukasz Langa

Łukasz Langa added the comment:

No.

Please, don't reopen without a patch. Better yet: move the discussion to 
python-ideas. Better yet: simply accept that you should either use -u or stop 
treating stdout/stderr as synchronized.

This issue has been closed twice already by distinct contributors. To keep 
reopening it is passive–aggressive behaviour, so is the wording of the title 
you chose for the report.

--
nosy: +lukasz.langa
status: open - closed

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



[issue16758] SubprocessStartupError

2012-12-23 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Lieutenant.Commander.Mohd.Nazri.Mohd.Nasir.RMN, can you please choose a shorter 
login name?

--
nosy: +serhiy.storchaka

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



[issue15302] Use argparse instead of getopt in test.regrtest

2012-12-23 Thread Andrew Svetlov

Andrew Svetlov added the comment:

Hi Chris.
Today we had python sprint and I've guessed to Anton to refactor the patch in 
good way with properly setting default values from regrtest.main to argparse 
args. Then use proper argparse actions for manipulating that args.

After all we can use Namespace object returned from argparse.parse() or 
argparse.parse_known_args() if needed as input for next processing.

It will be big enough patch but I like to move it forward after double checking.

regrtestlib.py name is good to me.

--

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



[issue7263] Fix set.intersection docstring

2012-12-23 Thread Juan Benavente Ponce

Juan Benavente Ponce added the comment:

set.intersection and frozenset.intersection docstrings are back to the wrong 
two-sets-only version in Python 3.3 (Python 2.7 is not affected):


intersection(...)
Return the intersection of two sets as a new set.

(i.e. all elements that are in both sets.)


 The correct docstring should be the one already submitted by Alexander 
Belopolsky:


intersection(...)
Return the intersection of two or more sets as a new set.

(i.e. all elements that are in all sets.)


 Thanks everyone for your great work and Merry Christmas!

--
nosy: +turgon
versions: +Python 3.3 -Python 2.7, Python 3.2

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



[issue16743] mmap accepts files 1 GB, but processes only 1 GB

2012-12-23 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

As I understand, the issue is that mmap slicing returns an empty string for 
large (but less than ssize_t limit) indices on 2.7.

May be it relates to 30-bit digits long integer implementation?

--
nosy: +serhiy.storchaka

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



[issue13863] import.c sometimes generates incorrect timestamps on Windows + NTFS

2012-12-23 Thread Brian Curtin

Brian Curtin added the comment:

Latest patch looks ok to me and the tests pass.

--

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



[issue14715] test.support.DirsOnSysPath should be replaced by importlib.test.util.import_state

2012-12-23 Thread Andrew Svetlov

Changes by Andrew Svetlov andrew.svet...@gmail.com:


--
nosy: +asvetlov

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



[issue15302] Use argparse instead of getopt in test.regrtest

2012-12-23 Thread Chris Jerdonek

Chris Jerdonek added the comment:

Yes, I agree with all of that but thought it would be easier to review if done 
incrementally as separate steps.  In any case, I will look for Anton's patch on 
the review tool in case I have any comments.

--

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



[issue7263] Fix set.intersection docstring

2012-12-23 Thread Juan Benavente Ponce

Juan Benavente Ponce added the comment:

Comparing the docstrings with the on-line documentation, I have found that, in 
addition to the already mentioned issue, the fact that many methods only 
require the first argument to be a set (or frozenset) object is not mentioned 
anywhere in the docstrings. Would it be useful if I write here a list of all 
the cases where this happens, and a possible alternative? An example:

Python 2.7
set.union
current docstring:
Return the union of sets as a new set.

(i.e. all elements that are in either set.)

possible enhancement:
union(set1, *iterables) -- new set

Return a new set with elements from set1 and all the iterables.

 Would it be a good idea to create a different docstring for the bound method? 
E.g:

unbound version:
union(set1, *iterables) -- new set

Return a new set with elements from set1 and all the iterables.

bound version:
set1.union(*iterables) -- new set

Return a new set with elements from set1 and all the iterables.

 If writing this list would be useful, please tell me so, and I will do it. 
Thanks for your time!

--

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



[issue16712] collections.abc.Sequence should not provide __reversed__

2012-12-23 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Guido put a number of non-optimal implementations in the ABCs.  His goal was to 
define the interface and to supply a working default implementation (see 
MutableMapping.clear() for a prime example).

In the case of __reversed__(), it is unfortunate that it slows down the default 
implementation of reverse().  The latter only runs faster because it is in C, 
not because of any algorithmic issue.

FWIW, the same is also true of Sequence.__contains__().  This logic in the ABC 
is straight-forward but slows down the code as compared to Python's C 
optimizations which can infer a __contains__ method from a sequence that 
defines __getitem__().

Given that the issue isn't algorithmic and is merely a C vs pure Python 
issue, I recommend leaving the current code as-is.

If someone truly cares about the speed issue, it would be an easy matter to 
supply a C helper function in the ABCs for speeding-up __reversed__ and 
__contains__ (for an example of how to do this, see _count_elements() in the 
collections module).

--

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



[issue16684] Unicode property value abbreviated names and long names

2012-12-23 Thread Terry J. Reedy

Terry J. Reedy added the comment:

I verified that the prototype file works in 2.7.3. I rewrote it for 3.3 using a 
refactored approach (and discovered that the site sometimes times out).

--
Added file: http://bugs.python.org/file28411/bc_ea_gc.py

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



[issue14470] Remove using of w9xopen in subprocess module

2012-12-23 Thread Roundup Robot

Roundup Robot added the comment:

New changeset c903e4f1121d by Brian Curtin in branch 'default':
Fix #14470. Remove w9xpopen per PEP 11.
http://hg.python.org/cpython/rev/c903e4f1121d

New changeset ae1845e4006a by Brian Curtin in branch 'default':
Add NEWS item for fixing #14470.
http://hg.python.org/cpython/rev/ae1845e4006a

--
nosy: +python-dev

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



[issue14470] Remove using of w9xopen in subprocess module

2012-12-23 Thread Brian Curtin

Changes by Brian Curtin br...@python.org:


--
resolution:  - fixed
status: open - closed

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



[issue879399] socket line buffering

2012-12-23 Thread Kristján Valur Jónsson

Kristján Valur Jónsson added the comment:

Sure, Leave it to me.

--

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



[issue16743] mmap accepts files 1 GB, but processes only 1 GB

2012-12-23 Thread Terry J. Reedy

Terry J. Reedy added the comment:

To me, Marc's title and penultimate sentence imply that he thinks that mmap 
should not accept such files. (But he should speak for himself.) As I said, not 
accepting such files could break working code.

As for the alternative of 'fixing' methods: Is it only slicing or other 
methods, even *every* method that 'misbehaves' when attempting to read (or 
write) beyond the 1 gig limit? I am guessing the last. If so, just about every 
method (inherited from bytearray, like slicing, or mmap specific) would need a 
fix conditional on the build and access location (and OS or hardware?).

Even for slices, what change would you (or anyone) make? Keep in mind that is 
it a *feature* of slices that they generally always work, and that this is 
specifically true of bytearrays. (Memory-mapped file objects behave like both 
bytearray and like file objects.) 

I am actually a bit surprised that the limit is 1 gb rather than 2, 3, or 4 gb. 
Is it the same on *nix? What is the limit for a bytearray on Win 7?

--

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



  1   2   >