sqlparse 0.1.6

2013-01-01 Thread Andi Albrecht
I'm pleased to announce sqlparse 0.1.5.

sqlparse is a non-validating SQL parser module.

Download:
http://pypi.python.org/packages/source/s/sqlparse/sqlparse-0.1.6.tar.gz#md5=2946514fbd29ea2a18ba398da171fbd2

This release improves Python 3 compatibility and has some minor bug fixes.

Changes since 0.1.5
===

sqlparse is now compatible with Python 3 without any patches. The
Python 3 version is generated during install by 2to3. You'll need
distribute to install sqlparse for Python 3.

Bug Fixes
 * Fix parsing error with dollar-quoted procedure bodies (issue83).

Other
 * Documentation updates.
 * Test suite now uses tox and py.test.
 * py3k fixes (by vthriller).
 * py3k fixes in setup.py (by Florian Bauer).
 * setup.py now requires distribute (by Florian Bauer).

Best regards  a happy new year to everyone!

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

Support the Python Software Foundation:
http://www.python.org/psf/donations/


Python debugger release 0.2.0

2013-01-01 Thread rocky . bernstein
pydbgr is a somewhat large Python debugger modelled on the gdb command set. 
(Yes, I know this name is really horrible).

I am pleased (or is it relieved?) to release a version of pydbr that has a 
couple of features I have in other debuggers I've written, namely:

1. Terminal output is now syntax highlighted (via pygments). And other section 
or error like output uses terminal control too. To turn that off use set 
highlight display or the --no-highlight option when invoking the debugger.

2. Smart  eval. A plain eval will evaluate the source line of code that is 
about to be run. If you enter eval? Then the most common expression portion of 
the source line is evaluated. For example if the source line is
 x = 1
Then eval will just run that. You don't have to cut and paste that source line. 
And eval? will evaluate just the RHS or 1.

There are a number of other features that the other debuggers have that I would 
eventually like to add:
  * terminal debugger command completion
  * better formatting using terminal control of help possibly using 
textile-like syntax
  * syntax coloring disassembly code
  * debugger macros as python code

but since this eval and syntax highlighting were so important, I thought I 
would rather have more smaller releases than one larger one.

Releases are available on pypi or the code repository 
http://code.google.com/p/pydbgr/
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations/


Re: father class name

2013-01-01 Thread 88888 Dihedral
On Monday, December 31, 2012 12:18:48 PM UTC+8, contro opinion wrote:
 here is my haha  class
 class  haha(object):
   def  theprint(self):
     print i am here
 

The definition of a class named haha.

  haha().theprint()
 i am here
  haha(object).theprint()
 Traceback (most recent call last):
 
   File stdin, line 1, in module
 TypeError: object.__new__() takes no parameters
 
 why    haha(object).theprint()  get wrong output?

You don't have to type the base class object.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: dict comprehension question.

2013-01-01 Thread 88888 Dihedral
On Tuesday, January 1, 2013 11:10:48 AM UTC+8, Steven D'Aprano wrote:
 On Sat, 29 Dec 2012 18:56:57 -0500, Terry Reedy wrote:
 
 
 
  On 12/29/2012 2:48 PM, Quint Rankid wrote:
 
  
 
  Given a list like:
 
  w = [1, 2, 3, 1, 2, 4, 4, 5, 6, 1]
 
  I would like to be able to do the following as a dict comprehension. 
 
  a = {}
 
  for x in w:
 
   a[x] = a.get(x,0) + 1
 
  results in a having the value:
 
  {1: 3, 2: 2, 3: 1, 4: 2, 5: 1, 6: 1}
 
  
 
  Let me paraphrase this: I have nice, clear, straightforward,
 
  *comprehensible* code that I want to turn into an incomprehensible mess
 
  with a 'comprehension. That is the ironic allure of comprehensions.
 
 
 
 But... but... one liner! ONE LINNR Won't somebody think 
 
 of the lines I'll save
 
 
 
 *wink*
 
 
 
 
 
 In case it's not obvious, I'm 100% agreeing with Terry here. List comps 
 
 and dict comps are wonderful things, but they can't do everything, and 
 
 very often even if they can do something they shouldn't because it makes 
 
 the code inefficient or unreadable.
 
 
 
 There's nothing wrong with a two or three liner.
 
 
 
 
 
 
 
 -- 
 
 Steven

This is useful for not being choked in sorting a list
by the notorious quick-sort.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New to python, do I need an IDE or is vim still good enough?

2013-01-01 Thread Cameron Simpson
On 01Jan2013 03:46, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info 
wrote:
| On Sat, 29 Dec 2012 14:00:23 -0500, Mitya Sirenef wrote:
|  [...] For instance, if I need to change
|  a block inside parens, I type ci) (stands for change inside parens),
|  while with a regular editor I'd have to do it manually and by the time
|  I'm done, I'd forget the bigger picture of what I'm doing with the code.
| 
| See, by the time I remembered what obscure (to me) command to type, or 
| searched the help files and the Internet, I'd have forgotten what the 
| hell it was I was trying to do.

Well, the idea is that your fingers become familiar with the core
commands. An issue of practice. The more complex vi commands are usually
composed from smaller pieces, so the learning curve isn't as steep as it
initially appears. Eg % jumps to that matching bracket. And
_therefore_, c% changes all text from here to the matching bracket.
There's a whole host of these.

| With a GUI app, I can run the mouse over the menus and see a high-level 
| overview of everything the app can do in a matter of a second or two. 

Well, there is GVim, a GNome X11 interface to vim. I imagine it would
offer that kind of mode.

| (Perhaps three or five seconds if the app over-uses hierarchical menus.) 
| But with a text interface, commands are much less discoverable. I can 
| also use *spacial* memory to zero in on commands much more easily than 
| verbal memory -- I have no idea whether the command I want is called 
| Spam or Ham or Tinned Bully Beef, but I know it's in the top 
| quarter of the Lunch menu, and I will recognise it when I see it.

I must admit I find Apple's help search box neat this way - you can
type a keyword is it will actually find the menu item for you. Not that
I use this for vi, of course...

|  Another example: ap stands for indent a paragraph (separated by blank
|  lines). And there are many dozens if not hundreds such commands that
|  let you stay focused on the logic of your code.
| 
| Ah yes, the famous a for indent mnemonic. *wink*

No,  is indent: it means shift-right. For Python you'd set the
shiftwidth to 4 (well, I use 2). But again, that's a grammar. Like the
change example above it is  followed by a cursor motion. So I'm
quite fond of }. } means jump to next blank line (or end of
paragraph for a prose paradigm). So } means shift right from here to the
next blank line.

When your fingers know the cursor motion commands, folding any of them
into a compound command like c or  or  (guess what that one is)
requires almost no though. It's almost like speaking - you don't think
about grammar in your native language.

| It seems to me, that by the time I would have searched for the right 
| command to use, decided which of the (multiple) matching commands is the 
| right one, then used the command, it would have been quicker and less 
| distracting to have just done the editing by hand. But now I'm just 
| repeating myself.

To repeat yourself in vi you just type .. See? So much faster than
your paragraph above:-)

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

As your attorney, it is my duty to inform you that it is not important that
you understand what I'm doing or why you're paying me so much money. What's
important is that you continue to do so.
- Hunter S. Thompson's Samoan Attorney
-- 
http://mail.python.org/mailman/listinfo/python-list


pygame - importing GL - very bad...

2013-01-01 Thread someone

See this code (understand why I commented out first line):

# from OpenGL.GL import *
from OpenGL.GL import glEnable, GL_DEPTH_TEST, \
 glShadeModel, GL_SMOOTH, glClearColor, \
 GL_CULL_FACE, GL_BLEND, glBlendFunc, \
 GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, \
 glClear, GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT, \
 glLoadIdentity, glTranslate, glRotate, \
 glMultMatrixf, glPushMatrix, glCallList, \
 glPopMatrix, glDisable, GL_LIGHTING

The reason why I commented out the first line is that I use pylint and 
it reports: [W] Redefining built-in 'format' for this line.


From: http://www.logilab.org/card/pylintfeatures tell:
W0621: Redefining name %r from outer scope (line %s) Used when a
variable's name hide a name defined in the outer scope.

I don't like to redefine already defined names so therefore I had to 
outcomment first line and then keep on adding stuff until I could run my 
program... But this SUCKS! I can see that pygame hasn't been updated for 
a long while - not many users use it? I'm not very happy about this...


Any good / clever solution to this problem, so I avoid this nasty crappy 
work-around?


Any ideas / suggestions ?
Thanks.


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


Re: pygame - importing GL - very bad...

2013-01-01 Thread Chris Angelico
On Tue, Jan 1, 2013 at 10:00 PM, someone newsbo...@gmail.com wrote:
 See this code (understand why I commented out first line):

 # from OpenGL.GL import *
 from OpenGL.GL import glEnable, GL_DEPTH_TEST, \
  glShadeModel, GL_SMOOTH, glClearColor, \
  GL_CULL_FACE, GL_BLEND, glBlendFunc, \
  GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, \
  glClear, GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT, \
  glLoadIdentity, glTranslate, glRotate, \
  glMultMatrixf, glPushMatrix, glCallList, \
  glPopMatrix, glDisable, GL_LIGHTING

 Any good / clever solution to this problem, so I avoid this nasty crappy
 work-around?

You could simply

import OpenGL.GL as GL

and then use all those names as GL.glPopMatrix, GL.GL_LIGHTING, etc. I
don't know if that's better or worse.

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


Handling Special characters in python

2013-01-01 Thread anilkumar . dannina
I am facing one issue in my module. I am gathering data from sql server 
database. In the data that I got from db contains special characters like 
endash. Python was taking it as \x96. I require the same character(endash). 
How can I perform that. Can you please help me in resolving this issue.

Waiting for your reply.

Thanks,
D Anil Kumar
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pygame - importing GL - very bad...

2013-01-01 Thread Steven D'Aprano
On Tue, 01 Jan 2013 12:00:32 +0100, someone wrote:

 See this code (understand why I commented out first line):
 
 # from OpenGL.GL import *
[...]
 The reason why I commented out the first line is that I use pylint and
 it reports: [W] Redefining built-in 'format' for this line.
 
 From: http://www.logilab.org/card/pylintfeatures tell: W0621: Redefining
 name %r from outer scope (line %s) Used when a variable's name hide a
 name defined in the outer scope.
 
 I don't like to redefine already defined names so therefore I had to
 outcomment first line and then keep on adding stuff until I could run my
 program... But this SUCKS! I can see that pygame hasn't been updated for
 a long while - not many users use it? I'm not very happy about this...

from pygame import *
del format


pylint may still complain, but you can ignore it. By deleting the name 
format, that will unshadow the builtin format.


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


Re: Handling Special characters in python

2013-01-01 Thread Steven D'Aprano
On Tue, 01 Jan 2013 03:35:56 -0800, anilkumar.dannina wrote:

 I am facing one issue in my module. I am gathering data from sql server
 database. In the data that I got from db contains special characters
 like endash. Python was taking it as \x96. I require the same
 character(endash). How can I perform that. Can you please help me in
 resolving this issue.


endash is not a character, it is six characters.

On the other hand, \x96 is a single byte:

py c = u\x96
py assert len(c) == 1


But it is not a legal Unicode character:

py import unicodedata
py unicodedata.name(c)
Traceback (most recent call last):
  File stdin, line 1, in module
ValueError: no such name


So if it is not a Unicode character, it is probably a byte.

py c = \x96
py print c
�


To convert byte 0x96 to an n-dash character, you need to identify the 
encoding to use. 

(Aside: and *stop* using it. It is 2013 now, anyone who is not using 
UTF-8 is doing it wrong. Legacy encodings are still necessary for legacy 
data, but any new data should always using UTF-8.)

CP 1252 is one possible encoding, but there may be others:

py uc = c.decode('cp1252')
py unicodedata.name(uc)
'EN DASH'



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


Re: pygame - importing GL - very bad...

2013-01-01 Thread Peter Otten
someone wrote:

 See this code (understand why I commented out first line):
 
 # from OpenGL.GL import *
 from OpenGL.GL import glEnable, GL_DEPTH_TEST, \
   glShadeModel, GL_SMOOTH, glClearColor, \
   GL_CULL_FACE, GL_BLEND, glBlendFunc, \
   GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, \
   glClear, GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT, \
   glLoadIdentity, glTranslate, glRotate, \
   glMultMatrixf, glPushMatrix, glCallList, \
   glPopMatrix, glDisable, GL_LIGHTING
 
 The reason why I commented out the first line is that I use pylint and
 it reports: [W] Redefining built-in 'format' for this line.
 
 From: http://www.logilab.org/card/pylintfeatures tell:
 W0621: Redefining name %r from outer scope (line %s) Used when a
 variable's name hide a name defined in the outer scope.
 
 I don't like to redefine already defined names so therefore I had to
 outcomment first line and then keep on adding stuff until I could run my
 program... But this SUCKS! I can see that pygame hasn't been updated for
 a long while - not many users use it? I'm not very happy about this...
 
 Any good / clever solution to this problem, so I avoid this nasty crappy
 work-around?
 
 Any ideas / suggestions ?
 Thanks.

It turns out pylint is lying. The situation is equivalent to

$ cat module.py
for format in [42]:
pass
del format

$ cat main.py 
original_format = format
from module import *
assert format is original_format
$ python main.py

The assert doesn't trigger, so format is not redefined. But pylint complains 
anyway:

$ pylint main.py -rn
No config file found, using default configuration
* Module main
W:  2: Redefining built-in 'format'
C:  1: Missing docstring
C:  1: Invalid name original_format (should match (([A-Z_][A-Z0-9_]*)|
(__.*__))$)
W:  2: Wildcard import module

If you can ignore the warning about the wildcard import you should be able 
to ignore the redefining built-in warning, too. Personally I would avoid 
putting magic comments like

from module import * # pylint: disable=W0622

$ pylint main.py -rn
No config file found, using default configuration
* Module main
I:  2: Locally disabling W0622
C:  1: Missing docstring
C:  1: Invalid name original_format (should match (([A-Z_][A-Z0-9_]*)|
(__.*__))$)
W:  2: Wildcard import module

into the code.

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


Re: New to python, do I need an IDE or is vim still good enough?

2013-01-01 Thread Tim Chase

On 01/01/13 04:12, Cameron Simpson wrote:

I must admit I find Apple's help search box neat this way - you
can type a keyword is it will actually find the menu item for
you. Not that I use this for vi, of course...


If you've not used it, Vim's :helpgrep command provides full Vim 
regexp power for searching Vim's help.



No,  is indent: it means shift-right. For Python you'd set
the shiftwidth to 4


For PEP8, you'd also want to set 'expandtab'.  Just to bring my 
semi-OT reply back around to Python :-)


-tkc



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


Re: pickle module doens't work

2013-01-01 Thread Omer Korat
I am using the nltk.classify.MaxEntClassifier. This object has a set of labels, 
and a set of probabilities: P(label | features). It modifies this probability 
given data. SO for example, if you tell this object that the label L appears 
60% of the time with the feature F, then P(L | F) = 0.6. 
The point is, there is no way to access the probabilities directly. The 
object's 'classify' method uses these probabilities, but you can't call them as 
an object property. 
In order to adjust probabilities, you have to call the object's 'train' method, 
and feed classified data in.
So is there any way to save a MaxEntClassifier object, with its classification 
probabilities, without having to call the 'train' method?
-- 
http://mail.python.org/mailman/listinfo/python-list


got stuck in equation

2013-01-01 Thread usamazohad
hi . . my name is usama khan 
i am the student of civil engeering  and we got assignment to make a project 
program on flexible pavement design using python.
 
i know very litle about programing. still learning from tutorials. u can call 
me a beginner.
now i need to solve this equation so that i can put this in python but the 
formula of design is very complex 
 
Formula is :
 
log(W18) = (Z)(S)+9.36log(SN+1) 
-2.0+(log(dpsi/(4.5-1.5))(/(.40+1094/(SN+1)^2.5)+2.32log(Mr-)-8.07
 
every thing is constant except this SN. . i want to seperate SN like SN= rest 
of the stuff. how can i seprate it because manualy its impossible to take SN 
out.
so plz help me out
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: got stuck in equation

2013-01-01 Thread Chris Angelico
On Wed, Jan 2, 2013 at 2:40 AM,  usamazo...@gmail.com wrote:
 hi . . my name is usama khan
 i am the student of civil engeering  and we got assignment to make a project 
 program on flexible pavement design using python.

 i know very litle about programing. still learning from tutorials. u can call 
 me a beginner.
 now i need to solve this equation so that i can put this in python but the 
 formula of design is very complex

 Formula is :

 log(W18) = (Z)(S)+9.36log(SN+1) 
 -2.0+(log(dpsi/(4.5-1.5))(/(.40+1094/(SN+1)^2.5)+2.32log(Mr-)-8.07

 every thing is constant except this SN. . i want to seperate SN like SN= rest 
 of the stuff. how can i seprate it because manualy its impossible to take SN 
 out.
 so plz help me out

This isn't a Python question, it's an algebra one. I don't know what
Z, S, and so on are, but for the most part, the basic rule of solving
equations applies: Do the same thing to both sides and it's still
true. Work on it until you can isolate SN on one side.

I don't know what this bit means, though:

2.32log(Mr-)

Is this a transcription error? You can't subtract nullness from something.

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


Re: got stuck in equation

2013-01-01 Thread Dave Angel
On 01/01/2013 10:40 AM, usamazo...@gmail.com wrote:
 hi . . my name is usama khan 
 i am the student of civil engeering  and we got assignment to make a project 
 program on flexible pavement design using python.
  
 i know very litle about programing. still learning from tutorials. u can call 
 me a beginner.
 now i need to solve this equation so that i can put this in python but the 
 formula of design is very complex 
  
 Formula is :
  
 log(W18) = (Z)(S)+9.36log(SN+1) 
 -2.0+(log(dpsi/(4.5-1.5))(/(.40+1094/(SN+1)^2.5)+2.32log(Mr-)-8.07
  
 every thing is constant except this SN. . i want to seperate SN like SN= rest 
 of the stuff. how can i seprate it because manualy its impossible to take SN 
 out.
 so plz help me out

Tk Solver is (or was) a program for getting numerical results from
equations where you couldn't (or didn't want to) express the equation
with the independent variable isolated on its own side of the equals
sign.  I don't know where it's available for purchase or download now; 
I do see references to it on the web, plus books still available about
it.  Apparently it's up to version 5.

Anyway, since everything else is a constant, use some program like Tk
Solver to get the value for SN, then the Python program becomes simply:

   SN =  4.7732

or whatever.

On the other hand, perhaps you didn't mean the other values were
constant, but rather known.  For example, perhaps your program is
supposed to ask the user for values to W18, to dpsi, etc., then it is to
calculate one or more values for SN that make the equation work.


SN might be structural number as indicated on this web page:
   
http://classes.engr.oregonstate.edu/cce/winter2012/ce492/Modules/06_structural_design/06-3_body.htm

The big equation on that page looks kinda like the one you present,
though I didn't study every term.


1)
Is there a finite range of values that SN might fall into?  I know
nothing about pavement design, other than what I just read there, but
there might well be a specific range that's reasonable to expect.

2)
Take the present equation, and subtract log(w18) from both sides.  Now,
you want a value for SN that produces zero, or something close for the
left hand side.  Call that side error.  Is the value error
relatively predictable for changes in SN ?  For example, in the simplest
case, any increase in SN will result in an increase of error.  The worst
case would be where any tiny change in SN might result in enormous
changes in a random direction to error.

3)
Figure an acceptable value for error, so you'll know when you're close
enough.

4)
if the first three questions have good answers, then you could write a
function that transforms FN into error.  Then write a controlling loop
that calls that function repeatedly, picking values for FN that will
converge the error into ever-smaller value.  The first iteration might
go over the entire range, dividing it into maybe ten steps.  Then pick
the two smallest values for error, and treat those particular two FN
values as your new range.

Repeat until the error value is below the threshold figured in #3, or
until you've iterated an unreasonable number of times.

There are ways to improve on that, but they generally require you know
the approximate behavior of the function.  For example, Newton's method
is a method of calculating square roots, starting with end points of 1
and N, and it converges more rapidly because it effectively calculates
the slope of the curve over each range.





-- 

DaveA

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


Re: got stuck in equation

2013-01-01 Thread Dave Angel
On 01/01/2013 11:03 AM, Chris Angelico wrote:
 On Wed, Jan 2, 2013 at 2:40 AM,  usamazo...@gmail.com wrote:
 hi . . my name is usama khan
 i am the student of civil engeering  and we got assignment to make a project 
 program on flexible pavement design using python.

 i know very litle about programing. still learning from tutorials. u can 
 call me a beginner.
 now i need to solve this equation so that i can put this in python but the 
 formula of design is very complex

 Formula is :

 log(W18) = (Z)(S)+9.36log(SN+1) 
 -2.0+(log(dpsi/(4.5-1.5))(/(.40+1094/(SN+1)^2.5)+2.32log(Mr-)-8.07

 every thing is constant except this SN. . i want to seperate SN like SN= 
 rest of the stuff. how can i seprate it because manualy its impossible to 
 take SN out.
 so plz help me out
 This isn't a Python question, it's an algebra one. I don't know what
 Z, S, and so on are, but for the most part, the basic rule of solving
 equations applies: Do the same thing to both sides and it's still
 true. Work on it until you can isolate SN on one side.

Such a rule may not be able to solve an equation when there SN appears
more than once on the RHS, and where it's inside a transcental
function.  I don't consider this an algebra problem, but a programming
problem.

 I don't know what this bit means, though:

 2.32log(Mr-)

 Is this a transcription error? You can't subtract nullness from something.

 ChrisA

Mr-   was apparently intended to mean M sub r,  the subgrade resilient
modulus
http://classes.engr.oregonstate.edu/cce/winter2012/ce492/Modules/04_design_parameters/04-2_body.htm#mr
 (in
psi).  Just a number.

The only thing i know about any of this is from here:
  
http://classes.engr.oregonstate.edu/cce/winter2012/ce492/Modules/06_structural_design/06-3_body.htm



-- 

DaveA

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


Re: got stuck in equation

2013-01-01 Thread Usama Khan
am just a begginer bro. . jus learnt if elif while nd for loop. . 

can u just display me the coding u want. .it could save my time that i have 
while searchning SN out. . i will give u that dependable variables values. .

nd SN range 4 inches to 13.5 inches

log(w18)=50x10^6
Z=-1.645
S=0.45
dpsi=2.5
Mr=5800

now can u give me the coding of this equation as i need to save my time. . .i 
am learning from tutorials. . so its taking lot of time. kindly consider my 
request nd give me the code so that i can put it. .i dont want to losen up my 
grade. .am trying hard. . .

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


Re: got stuck in equation

2013-01-01 Thread Usama Khan
Sn range is given in here. . 

www.dot.state.fl.us/rddesign/DS/08/IDx/514.pdf
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: got stuck in equation

2013-01-01 Thread Chris Angelico
On Wed, Jan 2, 2013 at 3:42 AM, Dave Angel d...@davea.name wrote:
 On 01/01/2013 11:03 AM, Chris Angelico wrote:
 This isn't a Python question, it's an algebra one. I don't know what
 Z, S, and so on are, but for the most part, the basic rule of solving
 equations applies: Do the same thing to both sides and it's still
 true. Work on it until you can isolate SN on one side.

 Such a rule may not be able to solve an equation when there SN appears
 more than once on the RHS, and where it's inside a transcental
 function.  I don't consider this an algebra problem, but a programming
 problem.

It's a tad more complicated than your average equation, and I haven't
the time now to prove the point by actually solving it, but every
operation that I can see in that formula can be reversed. The hairy
bit is that there are two references to SN, so it's going to be a bit
messy to untangle, and might end up as a higher-order equation.

But you're likely right that other forms of solver may be more useful
here. Algebra definitely _could_ be the solution, but it isn't
necessarily the best.

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


Re: got stuck in equation

2013-01-01 Thread Roy Smith
In article mailman.1521.1357061130.29569.python-l...@python.org,
 Usama Khan usamazo...@gmail.com wrote:

 am just a begginer bro.

That's fine, we were all beginners once.  You will discover that people 
here are willing to invest a lot of time and effort helping beginners 
get started.
 
 now can u give me the coding of this equation as i need to save my time. . .i 
 am learning from tutorials. . so its taking lot of time. kindly consider my 
 request nd give me the code so that i can put it. .i dont want to losen up my 
 grade. .am trying hard. . .

You will also discover that people are not willing to invest any effort 
to help if you are not also willing to invest your own effort.  Nobody 
is going to just give you some code for your homework assignment so you 
don't have to put any time into it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: got stuck in equation

2013-01-01 Thread Chris Angelico
On Wed, Jan 2, 2013 at 4:25 AM, Usama Khan usamazo...@gmail.com wrote:
 now can u give me the coding of this equation as i need to save my time. . .i 
 am learning from tutorials. . so its taking lot of time. kindly consider my 
 request nd give me the code so that i can put it. .i dont want to losen up my 
 grade. .am trying hard. . .

You don't want to lose your grade, so you ask someone else to do your
work for you. You haven't said what sort of class this is, but I see
two likely possibilities:

1) It's a programming class. Either you ought to be able to solve this
in the class (in which case, look to your source material as it's
almost certainly there - this is way more complicated maths than your
average programming class wants as an ancillary), or you shouldn't be
doing this part at all, and you can achieve the program's goal without
actually running the maths.

2) It's a course on something else (engineering?), to which this
formula is central. Then you ought to understand the mathematics of
it, regardless of the code.

Either way, posting urgent messages to python-list asking for someone
to *give you the code* is NOT the way to do things. We'll help you to
learn; we won't help you to get grades you haven't merited. There are
plenty of Q'n'A web sites out there with low standards and no
scruples, but please just make sure you never build a bridge that I'll
be travelling over.

Read this, it'll help explain what people think of these sorts of questions:
http://www.catb.org/esr/faqs/smart-questions.html#homework

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


Re: got stuck in equation

2013-01-01 Thread Usama Khan
u r right bro. .  am serving my time. .realy i dont need a short cut code. .

nor its a programing class. . 
i have chosen tis project on my own so that we can aviod that graph procedure. .

i guess the program i am making on python has many many things. .not just the 
iteration. .i am not that cheap really to cheat my DS(director of studies). .i 
swear. .

as i told i am half civil engieer. .in 5 th semester presently. .

am ready to learn. . .still learning from tutorialz of tekboi and investros 
and that book name python programing for absolute begginers 

kindly understand me. .i can give u my time. .u got me wrong. i just ask for 
the coding of solving this formula as its not in the book as well as tutorialz. 
:(

thanks for the concern. .
regards

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


Re: got stuck in equation

2013-01-01 Thread Usama Khan
how shud i intiate this equation myself. .can u give me some links to solve 
that myself. . am ready already. .its a chalange for me now. . .i just 
requested for a code as i dont know nothing about iteration of that much 
complex equation not the entire program. . 

so kindly show me the way. .i will do it myself. .nd remember plz am nt that 
cheap to cheat. .cheater doesnot worry about grades. .just remember this. .he 
just wants to clear the subject. . i have cleared the subject with excellent 
marks. .just spoiling my end semester vacation to get good grade and expereince 
in programing. . . its totaly optional to go for project, internship or 
vacationz. .nd i have chosen up the project. . .i hope i have clearified your 
doubt regarding my amnitions and concerns. . ??

so kindly show me the way. .i will go myself on that way. .because i dont know 
what way should go for this beautiful complex equatuion. .:)

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


Re: Handling Special characters in python

2013-01-01 Thread Chris Rebert
On Jan 1, 2013 3:41 AM, anilkumar.dann...@gmail.com wrote:

 I am facing one issue in my module. I am gathering data from sql server
database. In the data that I got from db contains special characters like
endash. Python was taking it as \x96. I require the same
character(endash). How can I perform that. Can you please help me in
resolving this issue.

1. What library are you using to access the database?
2. To confirm, it's a Microsoft SQL Server database?
3. What OS are you on?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New to python, do I need an IDE or is vim still good enough?

2013-01-01 Thread Mitya Sirenef

On 12/31/2012 10:46 PM, Steven D'Aprano wrote:

On Sat, 29 Dec 2012 14:00:23  -0500, Mitya Sirenef wrote:


 I think the general idea is that with editors like Vim you don't get
 distracted by having to do some kind of an editor task, letting you keep
 your full attention on the code logic. For instance, if I need to change
 a block inside parens, I type ci) (stands for change inside parens),
 while with a regular editor I'd have to do it manually and by the time
 I'm done, I'd forget the bigger picture of what I'm doing with the code.

 See, by the time I remembered what obscure (to me) command to type, or
 searched the help files and the Internet, I'd have forgotten what the
 hell it was I was trying to do. Well, almost. My memory is not quite that
 bad, but it would certainly be a much bigger disruption to my coding than
 just doing the edit by hand.


I would agree with you if I had to look up a command every time I use
it. The way it really works for me is that either I use a command often
enough that I remember it from the first time I looked it up, and the
memory is reinforced every time I use it, OR it's such a rare command
that looking it up is not a problem (obviously if it's faster to do it
by hand than to look it up, I can do that, as well, which in Vim means
using lower level commands that still don't require you leaving the home
row.)




 I do love the power of command line tools, but I think that for rich
 applications like editors, the interface is so clunky that I'd rather use
 a less-powerful editor, and do more editing manually, than try to
 memorize hundreds of commands.


Clunky is the last word I'd use to describe it (ok maybe for Emacs :-)
I probably remember about 200 commands, plus or minus, but a lot of them
fit into a consistent scheme which makes them much easier to remember:
there's (change delete yank vis-select)*(inner outer)*(letter word WORD 
paragraph )]} )


(Where word includes 'keyword' characters and WORD is separated by spaces).

So, these correspond to commands (cdyv)(ia)(lwWp)]}).

Therefore, deleting 3 WORDs is 3daW (mnemonic: del a WORD 3 times).

I think I have a pretty bad memory but I remembered all of these
commands a few at a time without too much trouble. And they're extremely
useful even now as I'm editing this email.





 With a GUI app, I can run the mouse over the menus and see a high-level
 overview of everything the app can do in a matter of a second or two.
 (Perhaps three or five seconds if the app over-uses hierarchical menus.)
 But with a text interface, commands are much less discoverable. I can
 also use *spacial* memory to zero in on commands much more easily than
 verbal memory -- I have no idea whether the command I want is called
 Spam or Ham or Tinned Bully Beef, but I know it's in the top
 quarter of the Lunch menu, and I will recognise it when I see it.


It's not a binary choice, GVim has a customizable menu system with a
simple text format for adding menus (from Vim manual):

To create a new menu item, use the :menu commands.  They are 
mostly like
the :map set of commands but the first argument is a menu item 
name, given

as a path of menus and submenus with a '.' between them. eg:

   :menu File.Save  :wCR
   :inoremenu File.Save  C-O:wCR
   :menu Edit.Big\ Changes.Delete\ All\ Spaces  :%s/[ ^I]//gCR




 On the other hand, it's a lot harder to use a GUI app over a slow SSH
 connection to a remote machine in a foreign country over a flaky link
 than it is to use a command line or text-interface app.


With GVim, you can use gui menus just as easily when you open a file
remotely.





 Another example: ap stands for indent a paragraph (separated by blank
 lines). And there are many dozens if not hundreds such commands that
 let you stay focused on the logic of your code.

 Ah yes, the famous a for indent mnemonic. *wink*


Well, 'a' is mnemonic for 'a', fittingly ;-).  is for indent, just as 
is for dedent. 'a' is to distinguish from inner paragraph command,
which omits blank lines after the paragraph (which matter for other
commands, but not for indent/dedent.): ip .


 - mitya


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

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


got stuck in equation

2013-01-01 Thread Usama Khan
kindly let me know how to solve complex equation in pyhton. . ??
nd then use that equation in program. . ??

am desperate to learn but i guess the posters are a bit angry with me that i 
asked the code for solving that equation. .plzz help me out,. . 

am here to learn. . !!! 
just dont knwo the way to solve complex eqauation. .can some answer me. . ?
-- 
http://mail.python.org/mailman/listinfo/python-list


how to solve complex equation?

2013-01-01 Thread Usama Khan
how to solve complex equation in pyhton? and then use it to make a program. . i 
have created new post as my last post is i guessed ranked as a cheater. .:(

i know very litle about python as well as programing. . 

which equation am taliking u will be thinking. . i am giving u the link kindly 
c that equation. . n kindly let me know the way. . 

https://groups.google.com/forum/?fromgroups=#!topic/comp.lang.python/cxG7DLxXgmo
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New to python, do I need an IDE or is vim still good enough?

2013-01-01 Thread Roy Smith
In article mailman.1528.1357065822.29569.python-l...@python.org,
 Mitya Sirenef msire...@lightbird.net wrote:

 Clunky is the last word I'd use to describe it (ok maybe for Emacs :-)
 I probably remember about 200 commands, plus or minus, but a lot of them
 fit into a consistent scheme which makes them much easier to remember

At some point, it becomes muscle memory, which means you don't even 
consciously know what you're typing.  Your brain just says, delete the 
next three words and your fingers move in some way which causes that to 
happen.  This is certainly true with emacs, and I imagine it's just as 
true with people who use inferior editors :-)

I used to do a bunch of pair programming with another emacs power user.  
Every once in a while, one of us would say something like, What did you 
just do?, when the other performed some emacs technique one of us was 
not familiar with.  Invariably, the answer would be, I don't know, and 
you would have to back up and recreate the key sequence.  Or, just run 
C-? l, which tells you the last 100 characters you typed.

Case in point.  I use C-? l moderately often, when I make some typo and 
I'm not sure what I did wrong.  But, despite the fact that my fingers 
now how to perform show me the last stuff I typed, I had to go hunting 
to find the actual keystrokes which does that when typing the above 
paragraph :-)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pickle module doens't work

2013-01-01 Thread Tim Roberts
Omer Korat animus.partum.univer...@gmail.com wrote:

I am using the nltk.classify.MaxEntClassifier. This object has a set of 
labels, and a set of probabilities: P(label | features). It modifies 
this probability given data. SO for example, if you tell this object 
that the label L appears 60% of the time with the feature F, then 
P(L | F) = 0.6. 

The point is, there is no way to access the probabilities directly. 
The object's 'classify' method uses these probabilities, but you can't
call them as an object property. 

Well, you have the source code, so you can certainly go look at the
implementation and see what the data is based on.

In order to adjust probabilities, you have to call the object's 'train' 
method, and feed classified data in.

The train method is not actually an object method, it's a class method.
It doesn't use any existing probabilities -- it returns a NEW
MaxEntClassifier based entirely on the training set.

So is there any way to save a MaxEntClassifier object, with its 
classification probabilities, without having to call the 'train' method?

If you haven't called the train method, there IS no MaxEntClassifier
object.  Once you have called train, you should be able to pickle the new
MaxEntClassifier and fetch it back with its state intact.
-- 
Tim Roberts, t...@probo.com
Providenza  Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New to python, do I need an IDE or is vim still good enough?

2013-01-01 Thread Mitya Sirenef

On 01/01/2013 02:02 PM, Roy Smith wrote:

In article  mailman.1528.1357065822.29569.python-l...@python.org,

 Mitya Sirenef msire...@lightbird.net wrote:

 Clunky is the last word I'd use to describe it (ok maybe for Emacs :-)
 I probably remember about 200 commands, plus or minus, but a lot of them
 fit into a consistent scheme which makes them much easier to remember

 At some point, it becomes muscle memory, which means you don't even
 consciously know what you're typing. Your brain just says, delete the
 next three words and your fingers move in some way which causes that to
 happen. This is certainly true with emacs, and I imagine it's just as
 true with people who use inferior editors :-)

 I used to do a bunch of pair programming with another emacs power user.
 Every once in a while, one of us would say something like, What did you
 just do?, when the other performed some emacs technique one of us was
 not familiar with. Invariably, the answer would be, I don't know, and
 you would have to back up and recreate the key sequence. Or, just run
 C-? l, which tells you the last 100 characters you typed.

 Case in point. I use C-? l moderately often, when I make some typo and
 I'm not sure what I did wrong. But, despite the fact that my fingers
 now how to perform show me the last stuff I typed, I had to go hunting
 to find the actual keystrokes which does that when typing the above
 paragraph :-)


That's true with Vim, as well, especially when I'm making a custom
mapping and I can NEVER remember what some combination does, even though
if I actually needed to use it, it pops right out, so to find out, I
have to try it and then I say, of course, dammit, I use this command 50
times every single day!; so it's a curious case of one-directional
memory.


subliminal 1-nanosecond BLINK TAG comment=hope this works, fingers
crossed content=let's face it, Vim is BETTER as it has always been!



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

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


Re: the class problem

2013-01-01 Thread Tim Roberts
contro opinion contropin...@gmail.com wrote:

here is my haha  class
class  haha(object):
  def  theprint(self):
print i am here

 haha().theprint()
i am here
 haha(object).theprint()
Traceback (most recent call last):
  File stdin, line 1, in module
TypeError: object.__new__() takes no parameters

why   haha(object).theprint()  get wrong output?

It doesn't -- that's the right output.  What did you expect it to do?

The line class haha(object) says that haha is a class that happens to
derive from the object base class.  The class is still simply called
haha, and to create an instance of the class haha, you write haha().
-- 
Tim Roberts, t...@probo.com
Providenza  Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Considering taking a hammer to the computer...

2013-01-01 Thread worldsbiggestsabresfan
OK, thank you all for your help yesterday!

Here's where we are today (using python 3.3.0)

He has everything running well except for the final calculations - he needs to 
be able to total the number of rooms in the hotel, as well as the number of 
occupied rooms.  We have tried several different things and can't come up with 
a successful command.  Any help you can give will be much appreciated!!

Here's what he's got:

#This program will calculate the occupancy rate of a hotel
floor_number = 0
rooms_on_floor = 0
occupied_rooms = 0
total_rooms = 0
total_occupied = 0



number_of_floors = int(input(How many floors are in the hotel?: ))
while number_of_floors  1:
print (Invalid input! Number must be 1 or more) 
number_of_floors = int(input(Enter the number of floors in the hotel: )) 

for i in range(number_of_floors): 
floor_number = floor_number + 1
print()
print (For floor #,floor_number) 
rooms_on_floor = int(input(How many rooms are on the floor ?:  ))
while rooms_on_floor  10:
print (Invalid input! Number must be 10 or more) 
rooms_on_floor = int(input(Enter the number of rooms on floor: ))

occupied_rooms = int(input(How many rooms on the floor are occupied?: ))

#CALCULATE OCCUPANCY RATE FOR FLOOR
occupancy_rate = occupied_rooms / rooms_on_floor
print (The occupancy rate for this floor is ,occupancy_rate)

#CALCULATE OCCUPANCY RATE FOR HOTEL
print()
total_rooms = sum(rooms_on_floor) #DOESN'T WORK!
total_occupied = sum(occupied_rooms) #DOESN'T WORK!
hotel_occupancy = total_occupied / total_rooms
vacant_rooms = total_rooms - total_occupied
print (The occupancy rate for this hotel is ,hotel_occupancy)
print (The total number of rooms at this hotel is ,total_rooms)
print (The number of occupied rooms at this hotel is ,total_occupied)
print (The number of vacant rooms at this hotel is ,vacant_rooms)

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


Re: Considering taking a hammer to the computer...

2013-01-01 Thread Matt Jones
rooms_on_floor is being set by the manual input for each floor iterated
over in your for loop.  My guess is your total_rooms value equals the rooms
from the last floor you processed.  Same goes for the occupied_rooms.
 You'll want a separate variable to increment after each occupied_rooms or
rooms_on_floor is received from the user.

something like...:

rooms_on_floor = int(input(Enter the number of rooms on floor: ))
total_rooms += rooms_on_floor

*Matt Jones*


On Tue, Jan 1, 2013 at 2:14 PM, worldsbiggestsabres...@gmail.com wrote:

 OK, thank you all for your help yesterday!

 Here's where we are today (using python 3.3.0)

 He has everything running well except for the final calculations - he
 needs to be able to total the number of rooms in the hotel, as well as the
 number of occupied rooms.  We have tried several different things and can't
 come up with a successful command.  Any help you can give will be much
 appreciated!!

 Here's what he's got:

 #This program will calculate the occupancy rate of a hotel
 floor_number = 0
 rooms_on_floor = 0
 occupied_rooms = 0
 total_rooms = 0
 total_occupied = 0



 number_of_floors = int(input(How many floors are in the hotel?: ))
 while number_of_floors  1:
 print (Invalid input! Number must be 1 or more)
 number_of_floors = int(input(Enter the number of floors in the hotel:
 ))

 for i in range(number_of_floors):
 floor_number = floor_number + 1
 print()
 print (For floor #,floor_number)
 rooms_on_floor = int(input(How many rooms are on the floor ?:  ))
 while rooms_on_floor  10:
 print (Invalid input! Number must be 10 or more)
 rooms_on_floor = int(input(Enter the number of rooms on floor: ))

 occupied_rooms = int(input(How many rooms on the floor are occupied?:
 ))

 #CALCULATE OCCUPANCY RATE FOR FLOOR
 occupancy_rate = occupied_rooms / rooms_on_floor
 print (The occupancy rate for this floor is ,occupancy_rate)

 #CALCULATE OCCUPANCY RATE FOR HOTEL
 print()
 total_rooms = sum(rooms_on_floor) #DOESN'T WORK!
 total_occupied = sum(occupied_rooms) #DOESN'T WORK!
 hotel_occupancy = total_occupied / total_rooms
 vacant_rooms = total_rooms - total_occupied
 print (The occupancy rate for this hotel is ,hotel_occupancy)
 print (The total number of rooms at this hotel is ,total_rooms)
 print (The number of occupied rooms at this hotel is ,total_occupied)
 print (The number of vacant rooms at this hotel is ,vacant_rooms)

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

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


Re: got stuck in equation

2013-01-01 Thread Tim Roberts
usamazo...@gmail.com wrote:
 
i know very litle about programing. still learning from tutorials. u can call 
me a beginner.
now i need to solve this equation so that i can put this in python but the 
formula of design is very complex 
 
Formula is :
 
log(W18) = (Z)(S)+9.36log(SN+1) 
-2.0+(log(dpsi/(4.5-1.5))(/(.40+1094/(SN+1)^2.5)+2.32log(Mr-)-8.07
 
every thing is constant except this SN. . i want to seperate SN like SN= 
rest of the stuff. how can i seprate it because manualy its impossible to
take SN out.

Right.  Algebraically, it isn't practical to solve this for SN.  That
probably means you're going to need a iterative solution.  That is, you
start with a guess, see how far off you are, and refine the guess until you
narrow in on a solution.  That means you'll have to figure out whether
raising SN gets you closer or farther away from a solution.
-- 
Tim Roberts, t...@probo.com
Providenza  Boekelheide, Inc.
-- 
http://mail.python.org/mailman/listinfo/python-list



Re: how to solve complex equation?

2013-01-01 Thread Jens Thoms Toerring
Usama Khan usamazo...@gmail.com wrote:
 how to solve complex equation in pyhton? and then use it to make a program.
 . i have created new post as my last post is i guessed ranked as a cheater.
 .:(

 i know very litle about python as well as programing. . 

 which equation am taliking u will be thinking. . i am giving u the link
 kindly c that equation. . n kindly let me know the way. .

 https://groups.google.com/forum/?fromgroups=#!topic/comp.lang.python/cxG7DLxXgmo

First of all, the equation given there is unusable (even the number
of parentheses doesn't match up). Propbably it's meant to be the
one someone else posted a link to:

http://classes.engr.oregonstate.edu/cce/winter2012/ce492/Modules/06_structural_design/06-3_body.htm

This thingy can't be solved on paper so you need some iterative
algorithm to find the solution. So waht you do is modify the equa-
tion so that you have 0 on one side and then consider the other
side to be a function of SN+1. Now the problem you're left with
is to find the value(s) of SN+1 (and thus of SN) where the func-
tion has a zero-crossing. A commonly use algorithms for finding
zero-crossings is Newton's method. You can find lots of sites on
the internet describing it in all neccessary detail. It boils
down to start with some guess for the result and then calculate
the next, better approximation via

  xn+1 = xn - f(xn) / f'(xn)

where f(xn)n) is the value of the function at point xn and
f'(xn) the value of the derivative of f (with respect to x)
also at xn. You repeat the process until the difference be-
tween xn an the next, better approximation, xn+1, has become
as small as you need it.

So it's very simple to implement and the ugliest bit is pro-
bably calculating the required derivative of the function with
respect to SN+1 (wbich you can take to be x).

 Regards, Jens
-- 
  \   Jens Thoms Toerring  ___  j...@toerring.de
   \__  http://toerring.de
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Considering taking a hammer to the computer...

2013-01-01 Thread worldsbiggestsabresfan
That's it!!!  Thank you, Matt!!  project done! :)

Thank you all, very much.

Happy New Year!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Considering taking a hammer to the computer...

2013-01-01 Thread Chris Angelico
On Wed, Jan 2, 2013 at 7:14 AM,  worldsbiggestsabres...@gmail.com wrote:
 floor_number = 0
 for i in range(number_of_floors):
 floor_number = floor_number + 1

Matt's already given you the part you need (and it seems to have
worked for you, yay!). Side point: Are you aware that i and
floor_number are always going to have the same value? You can simplify
this down to:

for floor_number in range(number_of_floors):

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


Re: pygame - importing GL - very bad...

2013-01-01 Thread alex23
On Jan 1, 9:00 pm, someone newsbo...@gmail.com wrote:
 I can see that pygame hasn't been updated for
 a long while - not many users use it?

It helps if you look in the right place:

pygame Last Updated 2012-12-29: https://bitbucket.org/pygame/pygame/src
pygame2: http://code.google.com/p/pgreloaded/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to solve complex equation?

2013-01-01 Thread Gary Herron

On 01/01/2013 11:02 AM, Usama Khan wrote:

how to solve complex equation in pyhton? and then use it to make a program. . i 
have created new post as my last post is i guessed ranked as a cheater. .:(

i know very litle about python as well as programing. .

which equation am taliking u will be thinking. . i am giving u the link kindly 
c that equation. . n kindly let me know the way. .

https://groups.google.com/forum/?fromgroups=#!topic/comp.lang.python/cxG7DLxXgmo


Please STOP asking this question, and try to understand the answers you 
have already been given.


Short answer:  This is NOT a python question, and you can't solve it in 
Python.


Longer answer:  This is a math question.  Some equations can be solved 
with algebra, and some can't, in which case perhaps you need some sort 
of a technique for numerical approximation.Other's have indicated 
that your problem probably falls into the later category.What YOU 
need to do is investigate iterative techniques for numerical solutions 
and pick one.  (And this Python list is CERTAINLY the wrong place for 
such math questions.)  Once you know what solution technique you want to 
use, you could then come back to this group and ask for help 
implementing it.


P.S.  I have implemented several such techniques, and I have taught 
college courses involving such techniques, and I'll say this:  What you 
ask is the subject of AT LEAST several hours of lectures and possibly 
several semesters worth of study.  No one is going to put that kind of 
time into answering your question here.


--
Dr. Gary Herron
Department of Computer Science
DigiPen Institute of Technology
(425) 895-4418

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


Re: how to solve complex equation?

2013-01-01 Thread alex23
On Jan 2, 5:02 am, Usama Khan usamazo...@gmail.com wrote:
 i have created new post as my last post is i guessed ranked as a cheater. .:(

Don't do this. Starting new threads on the same subject because you're
not happy with the response you're getting elsewhere is a surefire way
to end up in a lot of killfiles.

 i know very litle about python as well as programing. .

Then please stop asking people to write your code for you. For many of
us. this is our *profession*. Generally, we're here to help others 
ourselves understand Python better, not to work for free. If you don't
have the time or the ability to produce what you want, and it has
value to you, then offer to *pay* someone for their time  effort in
writing the code for you.
-- 
http://mail.python.org/mailman/listinfo/python-list


numpy has got newtonsmethod?

2013-01-01 Thread Usama Khan
my question is can we import newtonsmethod from nympy or sciPy?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ignore case only for a part of the regex?

2013-01-01 Thread Vlastimil Brom
2013/1/1 Steven D'Aprano steve+comp.lang.pyt...@pearwood.info:
 On Sun, 30 Dec 2012 10:20:19 -0500, Roy Smith wrote:

 The way I would typically do something like this is build my regexes in
 all lower case and .lower() the text I was matching against them.  I'm
 curious what you're doing where you want to enforce case sensitivity in
 one part of a header, but not in another.

 Well, sometimes you have things that are case sensitive, and other things
 which are not, and sometimes you need to match them at the same time. I
 don't think this is any more unusual than (say) wanting to match an
 otherwise lowercase word whether or not it comes at the start of a
 sentence:

 [Pp]rogramming

 is conceptually equivalent to match case-insensitive `p`, and case-
 sensitive `rogramming`.


 By the way, although there is probably nothing you can (easily) do about
 this prior to Python 3.3, converting to lowercase is not the right way to
 do case-insensitive matching. It happens to work correctly for ASCII, but
 it is not correct for all alphabetic characters.


 py 'Straße'.lower()
 'straße'
 py 'Straße'.upper()
 'STRASSE'


 The right way is to casefold first, then match:

 py 'Straße'.casefold()
 'strasse'


 Curiously, there is an uppercase ß in old German. In recent years some
 typographers have started using it instead of SS, but it's still rare,
 and the official German rules have ß transform into SS and vice versa.
 It's in Unicode, but few fonts show it:

 py unicodedata.lookup('LATIN CAPITAL LETTER SHARP S')
 'ẞ'



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

Hi,
just for completeness, the mentioned regex library can take care of
casfolding in case insensitive matching (in all supported versions:
Python 2.5-2.7 and 3.1-3.3); i.e.:
# case sensitive match:
 for m in regex.findall(urStraße, u STRAßE STRASSE STRAẞE Strasse Straße 
 ): print m
...
Straße

# case insensitive match:
 for m in regex.findall(ur(?i)Straße, u STRAßE STRASSE STRAẞE Strasse 
 Straße ): print m
...
STRAßE
STRAẞE
Straße

# case insensitive match with casefolding:
 for m in regex.findall(ur(?if)Straße, u STRAßE STRASSE STRAẞE Strasse 
 Straße ): print m
...
STRAßE
STRASSE
STRAẞE
Strasse
Straße



# after enabling the backwards incompatible modern matching behaviour,
casefolding is by default turned on for case insensitive matches
 for m in regex.findall(ur(?V1i)Straße, u STRAßE STRASSE STRAẞE Strasse 
 Straße ): print m
...
STRAßE
STRASSE
STRAẞE
Strasse
Straße



As a small addition, the originally posted pattern r'^Msg-(?:(?i)id):'
would actually work as expected in this modern matching mode in regex
- enabled with the V1 flag. In this case the flag-setting (?i) only
affects the following parts of the pattern, not the whole pattern like
in the current re and V0-compatibility-mode regex

 regex.findall(r(?V1)Msg-(?:(?i)id):, the regex should match  Msg-id:, 
 Msg-Id:, ...  but not  msg-id:, MSG-ID:  and so on)
['Msg-id:', 'Msg-Id:']


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


Re: how to solve complex equation?

2013-01-01 Thread Usama Khan
thanks :)

no issues. . :)

sorry for wasting ur precious time. . .sorry once again. . 


its mine problem now. . neither python. .nor the algebra. . .

sorry guys. dont mind. .:) dont get me wrong. .

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


Re: numpy has got newtonsmethod?

2013-01-01 Thread Chris Angelico
On Wed, Jan 2, 2013 at 10:01 AM, Usama Khan usamazo...@gmail.com wrote:
 my question is can we import newtonsmethod from nympy or sciPy?

http://www.catb.org/esr/faqs/smart-questions.html#classic

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


Re: pygame - importing GL - very bad...

2013-01-01 Thread someone

On 01/01/2013 12:13 PM, Chris Angelico wrote:
 On Tue, Jan 1, 2013 at 10:00 PM, someone newsbo...@gmail.com wrote:
 See this code (understand why I commented out first line):

 # from OpenGL.GL import *
 from OpenGL.GL import glEnable, GL_DEPTH_TEST, \
   glShadeModel, GL_SMOOTH, glClearColor, \
   GL_CULL_FACE, GL_BLEND, glBlendFunc, \
   GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, \
   glClear, GL_COLOR_BUFFER_BIT, GL_DEPTH_BUFFER_BIT, \
   glLoadIdentity, glTranslate, glRotate, \
   glMultMatrixf, glPushMatrix, glCallList, \
   glPopMatrix, glDisable, GL_LIGHTING

 Any good / clever solution to this problem, so I avoid this nasty crappy
 work-around?

 You could simply

 import OpenGL.GL as GL

 and then use all those names as GL.glPopMatrix, GL.GL_LIGHTING, etc. I
 don't know if that's better or worse.

You're right - but I forgot to write that even though this maybe 
should/is recommended many places then I've seen a lot of opengl code on 
the internet and IMHO NOBODY does that and it'll be a lot slower to type 
that in front of all the opengl commands...


So this solution is not something I like too... But I can see some other 
people came up with good solutions, which I didn't knew about..


Thank you.

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


Re: pygame - importing GL - very bad...

2013-01-01 Thread someone

On 01/01/2013 12:49 PM, Steven D'Aprano wrote:
 On Tue, 01 Jan 2013 12:00:32 +0100, someone wrote:

 See this code (understand why I commented out first line):

 # from OpenGL.GL import *
 [...]
 The reason why I commented out the first line is that I use pylint and
 it reports: [W] Redefining built-in 'format' for this line.

 From: http://www.logilab.org/card/pylintfeatures tell: W0621: Redefining
 name %r from outer scope (line %s) Used when a variable's name hide a
 name defined in the outer scope.

 I don't like to redefine already defined names so therefore I had to
 outcomment first line and then keep on adding stuff until I could run my
 program... But this SUCKS! I can see that pygame hasn't been updated for
 a long while - not many users use it? I'm not very happy about this...

 from pygame import *
 del format

Are you sure about this? Because I'm not (OTOH I'm maybe not as 
experienced in python as some of you)... Ipython log:



In [6]: test=format(43)

In [7]: type(test)
Out[7]: str

In [8]: from pygame import *

In [9]: test=format(43)

In [10]: type(test)
Out[10]: str

In [11]: del format
---
NameError Traceback (most recent call last)
ipython-input-11-028e6ffb84a8 in module()
 1 del format

NameError: name 'format' is not defined


What does this mean? Why does it say 'format cannot be deleted after I 
did the wildcard import ?


 pylint may still complain, but you can ignore it. By deleting the name
 format, that will unshadow the builtin format.

Are you sure?

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


Re: pygame - importing GL - very bad...

2013-01-01 Thread someone

On 01/01/2013 01:56 PM, Peter Otten wrote:
 someone wrote:

 It turns out pylint is lying. The situation is equivalent to

 $ cat module.py
 for format in [42]:
  pass
 del format

 $ cat main.py
 original_format = format
 from module import *
 assert format is original_format
 $ python main.py

 The assert doesn't trigger, so format is not redefined. But pylint 
complains

 anyway:

 $ pylint main.py -rn
 No config file found, using default configuration
 * Module main
 W:  2: Redefining built-in 'format'
 C:  1: Missing docstring
 C:  1: Invalid name original_format (should match (([A-Z_][A-Z0-9_]*)|
 (__.*__))$)
 W:  2: Wildcard import module

 If you can ignore the warning about the wildcard import you should be 
able


In the case of opengl import, I'll ignore the wildcard import warning. 
But in other cases I'll likely look a bit into it and see if I can avoid 
it or at least change it to something like: import OpenGL.GL as GL etc.


 to ignore the redefining built-in warning, too. Personally I would 
avoid

 putting magic comments like

 from module import * # pylint: disable=W0622

Oh, I just learned something new now... How come I cannot type #pylint: 
enable=W0622 in the line just below the import ?


Not so intuitively/logically for me...

 $ pylint main.py -rn
 No config file found, using default configuration
 * Module main
 I:  2: Locally disabling W0622
 C:  1: Missing docstring
 C:  1: Invalid name original_format (should match (([A-Z_][A-Z0-9_]*)|
 (__.*__))$)
 W:  2: Wildcard import module

 into the code.

Thank you very much...

Another thing is that I don't understand this warning:

Invalid name original_format (should match (([A-Z_][A-Z0-9_]*)|
 (__.*__))$)

I get it everywhere... I don't understand how it wants me to label my 
variables... Maybe I should disable this warning to get rid of it...




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


Re: numpy has got newtonsmethod?

2013-01-01 Thread Vlastimil Brom
2013/1/2 Usama Khan usamazo...@gmail.com:
 my question is can we import newtonsmethod from nympy or sciPy?
 --
 http://mail.python.org/mailman/listinfo/python-list

Hi,
After successfully installing SciPy
http://www.scipy.org/Download
you should be able to import the respective modules and use this
functionality such as
http://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.newton.html

you may also consider

mpmath
http://code.google.com/p/mpmath/
http://mpmath.googlecode.com/svn/trunk/doc/build/calculus/optimization.html

SymPy
http://sympy.org

or maybe some OpenOpt software
http://openopt.org

or other related libraries/frameworks available in python.

I am not at all competent to decide about the suitability for your
originally posted problem, but I guess, you may be able to find it out
based on your requirements and the features supported by these
libraries.

hth,
  vbr
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pygame - importing GL - very bad...

2013-01-01 Thread someone

On 01/01/2013 11:39 PM, alex23 wrote:

On Jan 1, 9:00 pm, someone newsbo...@gmail.com wrote:

I can see that pygame hasn't been updated for
a long while - not many users use it?


It helps if you look in the right place:

pygame Last Updated 2012-12-29: https://bitbucket.org/pygame/pygame/src
pygame2: http://code.google.com/p/pgreloaded/


Maybe... But if you look for stable releases here:

http://www.pygame.org/download.shtml

You'll find the top option: 1.9.1 Packages (August 6th 2009)


And then previous releases is just below 1.9.1:

pygame-1.9.0release.tar.gz ~ 1.4M - August 1, 2009
pygame-1.8.1release.tar.gz ~ 1.4M - July 30, 2008
pygame-1.8.0release.tar.gz ~ 1.4M - March 29, 2008
pygame-1.7.1release.tar.gz ~ 1.3M - August 16, 2005
1.7.0 ~ no source release was made.
pygame-1.6.2.tar.bz2 ~ 1140 kb -
pygame-1.6.tar.gz ~ 832 kb - October 23, 2003
pygame-1.5.tar.gz ~ 736 kb - May 30, 2002
pygame-1.4.tar.gz ~ 808 kb - Jan 30, 2002
pygame-1.3.tar.gz ~ 731 kb - Dec 19, 2001
pygame-1.2.tar.gz ~ 708 kb - Sep 4, 2001
pygame-1.1.tar.gz ~ 644 kb - Jun 23, 2001
pygame-1.0.tar.gz ~ 564 kb - Apr 5, 2001
pygame-0.9.tar.gz ~ 452 kb - Feb 13, 2001
pygame-0.5.tar.gz ~ 436 kb - Jan 6 14, 2001
pygame-0.4.tar.gz ~ 420 kb - Dec 14, 2000
pygame-0.3b.tar.gz ~ 367 kb - Nov 20, 2000
pygame-0.2b.tar.gz ~ 408 kb - Nov 3, 2000
pygame-0.1a.tar.gz ~ 300 kb - Oct 28, 2000


Back to year 2000...

Maybe they should get a grip on themselves and distribute a new stable 
releases in year 2013 - then it would at least SEEM to look as the 
project is not dead. But in any case, I'm happy with it - haven't 
experienced any big issues with pygame yet, so don't take this as I 
don't value what they do. Maybe they've made a great version back in 
2009 and it's so good that there wasn't any need for a newer stable 
version before 2013.


But it gives the impression that nothing happens, when so many years 
pass on...


Anyway, thanks a lot to all...

(And sorry I accidentally replied privately to some of you - in 
thunderbird I should hit the followup-button but maybe they've removed 
it and instead I keep on hitting reply - very confusing that the first 
button in thunderbird is reply instead of followup, which is what I 
always prefer to use (so other people can see the answers).


Thanks you for pointing out that (at least) something did happen on 
2012-12-29, when it looks a bit dead on the official homepage.



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


Re: Considering taking a hammer to the computer...

2013-01-01 Thread MRAB

On 2012-12-31 23:42, worldsbiggestsabres...@gmail.com wrote:

Hey :)

I'm trying to help my son with an assignment and spending hours making an inch 
of progress.  I know nothing about programming and I'm trying to learn, on my 
own, at a rate faster than possible. I would love a little help!

My son is taking an introductory course and his assignment is to use the loops for and 
while to create a program which calculates a hotel's occupancy rate. He has managed all 
of the inputs but needs help with the following:

1) The first question asked is how many floors are in the hotel - and then the 
questions are asked floor by floor.  We can't figure out how to get the program 
to stop questioning when the number of floors is reached.

2) He has programmed specific calculations for each floor, and now needs to 
have  calculations for the entire hotel based on the input about each floor.

Here is what he has done so far:


#This program will calculate the occupancy rate of a hotel
floor_number = 0


number_of_floors = int(input(How many floors are in the hotel?: ))
while number_of_floors  1:
 print (Invalid input!)
 number_of_floors = input(Enter the number of floors in the hotel: )
while number_of_floors  1:
 floor_number = floor_number + 1
 print()
 print (For floor #,floor_number)
 rooms_on_floor = int(input(How many rooms are on the floor ?:  ))
 while rooms_on_floor  10:
 print (Invalid input!)
 rooms_on_floor = int(input(Enter the number of rooms on floor: ))

 occupied_rooms = int(input(How many rooms on the floor are occupied?: ))

 #CALCULATE OCCUPANCY RATE FOR FLOOR
 occupancy_rate = occupied_rooms / rooms_on_floor
 print (The occupancy rate for this floor is ,occupancy_rate)



The following is what we believe needs to go in the program at the end except 
we can't figure out how to calculate it and make it all work :/ (alot of the 
terms have nothing at all to identify them yet...)

hotel_occupancy = total_occupied / total_rooms
print (The occupancy rate for this hotel is ,hotel_occupancy)
print (The total number of rooms at this hotel is ,total_rooms)
print (The number of occupied rooms at this hotel is ,total_occupied)
vacant_rooms = total_rooms - total_occupied
print (The number of vacant rooms at this hotel is ,vacant_rooms)

We've searched and read and we found things about the break and pass 
commands but his teacher will not allow them because they haven't been taught yet.

If you have any ideas and can take a minute to help, that would be great :)

Thank you!


Firstly, the second 'while' loop repeats while number_of_floors  1,
but the number of floors is never changed within that loop, so the loop
will repeat forever. Also, if there's only one floor, it won't perform
the body of the loop at all!

Secondly, you're not calculating any totals for the final section to
use.

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


Re: Considering taking a hammer to the computer...

2013-01-01 Thread Dave Angel
On 01/01/2013 03:14 PM, worldsbiggestsabres...@gmail.com wrote:
 OK, thank you all for your help yesterday!

 Here's where we are today (using python 3.3.0)

 He has everything running well except for the final calculations - he needs 
 to be able to total the number of rooms in the hotel, as well as the number 
 of occupied rooms.  We have tried several different things and can't come up 
 with a successful command.  Any help you can give will be much appreciated!!
There are two ways to get those totals, depending on whether you know
how to work lists or not.  If you do, then you should make a list of
occupied_rooms, and sum() it at the end, and make a list of
rooms_on_flow, and sum that at the end.

But as you discovered, sum() won't work on an int (BTW, you should give
the entire traceback instead of saying doesn't work.  In this case, it
was obvious, but it might not be.)

On the other hand, if you don't know what a list is, then you need to
accumulate those numbers as you go.  Either way, you need extra
variables to represent the whole hotel, and you need to do something
inside the loop to adjust those variables.



-- 

DaveA

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


Re: Considering taking a hammer to the computer...

2013-01-01 Thread Dave Angel
On 01/01/2013 05:01 PM, Chris Angelico wrote:
 On Wed, Jan 2, 2013 at 7:14 AM,  worldsbiggestsabres...@gmail.com wrote:
 floor_number = 0
 for i in range(number_of_floors):
 floor_number = floor_number + 1
 Matt's already given you the part you need (and it seems to have
 worked for you, yay!). Side point: Are you aware that i and
 floor_number are always going to have the same value? You can simplify
 this down to:

 for floor_number in range(number_of_floors):

 ChrisA

Actually, floor_number is one higher.  The easiest way to fix that is to
adjust the range() parms.

for floor_number in range(1, 1+number_of_floors):

Naturally, in some hotels that might not have any rooms on one of the
floors.  Divide by zero.


-- 

DaveA

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


Re: New to python, do I need an IDE or is vim still good enough?

2013-01-01 Thread jussij
FWIW on the Windows platform the Zeus IDE has support for Python:

http://www.zeusedit.com/python.html

Zeus does the standard Python syntax highlighting, code completion, smart 
indenting, class browsing, code folding etc.

Zeus also has limited Python debugger support and is fully scriptable 
in Python.

Jussi Jumppanen
Author: Zeus Editor
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: numpy has got newtonsmethod?

2013-01-01 Thread Usama Khan
thanks. . 

but how to instal scipy. because its in .rar form. .i have extracted the files 
to the place where python2.7 is installed. . but everytime i write import 
sciPy. .it give me error. . 
nd regarding ur question. .

its a long story telling u why i have just ask this breif question. . anyways 
thanks . .waiing for ur reply. .

i just want to iterate my complex equation. .

how can i import newtonsmethod from numpy as numpy is successfully insalled. 
.:) 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: numpy has got newtonsmethod?

2013-01-01 Thread Usama Khan
yeah i have read it sir CrisA. .:)

thanks . .:)

i wish i could make u watch my google search list of last two days nd idm 
downlaodng list of last two days. .text me ur email id. .i can show u my 
efforts. .
:)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: numpy has got newtonsmethod?

2013-01-01 Thread Usama Khan
Traceback (most recent call last):
  File C:/Python27/12.py, line 4, in module
import scipy  # also has log
  File C:/Python27\scipy\__init__.py, line 114, in module
raise ImportError(msg)
ImportError: Error importing scipy: you cannot import scipy while
being in scipy source directory; please exit the scipy source
tree first, and relaunch your python intepreter.
 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: numpy has got newtonsmethod?

2013-01-01 Thread alex23
On Jan 2, 10:28 am, Usama Khan usamazo...@gmail.com wrote:
 but how to instal scipy. because its in .rar form. .i have extracted
 the files to the place where python2.7 is installed. . but everytime
 i write import sciPy. .it give me error. .

If you want help, you have to remember we can't magically detect your
development environment. Of course, you could always just read
http://www.scipy.org/Installing_SciPy and report back with explicit
information on _what didn't work_.

 i just want to iterate my complex equation. .
 how can i import newtonsmethod from numpy as numpy is successfully
 insalled. .:)

Repeating the question because you're not listening to the answers
given is growing tedious. Vlastimil provided you with a _direct link_
to the relevant documentation: 
http://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.newton.html

If you can't import from scipy, then _fix that problem first_, because
that's what you need to be able to do the rest.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: numpy has got newtonsmethod?

2013-01-01 Thread alex23
On Jan 2, 10:34 am, Usama Khan usamazo...@gmail.com wrote:
 i wish i could make u watch my google search list of last two days nd idm 
 downlaodng list of last two days. .text me ur email id. .i can show u my 
 efforts. .
 :)

I'm guessing it would show you flailing around and _not_ typing numpy
newton's method, because that's all it took to bring up the direct
link to the scipy documentation on importing  using it (first link),
as well as full code samples of variants implemented directly in
numpy.

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


Re: numpy has got newtonsmethod?

2013-01-01 Thread Usama Khan
k thanks :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: numpy has got newtonsmethod?

2013-01-01 Thread Vlastimil Brom
2013/1/2 Usama Khan usamazo...@gmail.com:
 thanks. .

 but how to instal scipy. because its in .rar form. .i have extracted the 
 files to the place where python2.7 is installed. . but everytime i write 
 import sciPy. .it give me error. .
 nd regarding ur question. .

 its a long story telling u why i have just ask this breif question. . anyways 
 thanks . .waiing for ur reply. .

 i just want to iterate my complex equation. .

 how can i import newtonsmethod from numpy as numpy is successfully insalled. 
 .:)
 --
 http://mail.python.org/mailman/listinfo/python-list

I assume (based on the traceback you posted), that you are using
windows; in that case you can use the appropriate ready made
installers for SciPy, instead of the source files; see.:
http://sourceforge.net/projects/scipy/files/scipy/0.11.0/
e.g.:
scipy-0.11.0-win32-superpack-python2.7.exe


hth,
  vbr
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: numpy has got newtonsmethod?

2013-01-01 Thread Steven D'Aprano
On Tue, 01 Jan 2013 16:42:13 -0800, Usama Khan wrote:

 Traceback (most recent call last):
   File C:/Python27/12.py, line 4, in module
 import scipy  # also has log
   File C:/Python27\scipy\__init__.py, line 114, in module
 raise ImportError(msg)
 ImportError: Error importing scipy: you cannot import scipy while
 being in scipy source directory; please exit the scipy source
 tree first, and relaunch your python intepreter.


Please read the error message. It tells you exactly what you need to do.

You cannot import scipy while being in scipy source directory; please 
exit the scipy source tree first, and relaunch your python interpreter.

Do you understand what a source directory is? It is a directory (a 
folder) with the source code in it. Leave the scipy directory, and re-
start Python, then try importing scipy.



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


Noob: Trying to run two python scrips on a pfsense/freeBSD for the OWL-Intuition-LC

2013-01-01 Thread vbhoj74
Hi,

I wrote couple of scrips to work with OWL-intution-LC home/office electricity 
monitor. The concept of the first scrip (owl.py) to capture network multicast 
from the OWL gateway and write to a .csv file has been taken from a raspberrypi 
forum and further developed upon to work with sqlite. The second scrip 
(responder.py)keeps checking a mail account for any email queries received and 
responds with a detailed electricity report to the sender. 

I've been using owl.py since some days  works fine on the pfsense/freebsd, it 
has been set to start on boot using shellcmd. The second scrip also works when 
I execute manually from the shell, but it does not seems to start upon boot how 
I did for owl.py. I cannot find anything in /var/log/system.log about execution 
or failure of either scrips.

This question may not exactly relate with python but any help would be 
appreciated.

Another Q I wanted to ask or rather confirm, I think python does not log 
anything from scrip runtime/termination and that there is a log library that 
needs to be used. I find using the log library adding bulk to the code and for 
every line I suspect of failure in the code I would need to put in an exception 
to create log ? Is there a better way of logging where it just logs the reason 
on scrip termination ? I just want to log the msg it shows when manually run in 
a shell. - Thanks.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pygame - importing GL - very bad...

2013-01-01 Thread Nobody
On Wed, 02 Jan 2013 00:49:36 +0100, someone wrote:

 In [11]: del format
 ---
 NameError Traceback (most recent call last)
 ipython-input-11-028e6ffb84a8 in module()
  1 del format
 
 NameError: name 'format' is not defined
 
 
 What does this mean? Why does it say 'format cannot be deleted after I 
 did the wildcard import ?

You can't delete built-in names. 

It has nothing to do with the wildcard import. The PyOpenGL modules delete
format from the module's variables as soon as they are finished with
it, so the set of names created by the wildcard import doesn't include
format.

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


Re: pygame - importing GL - very bad...

2013-01-01 Thread someone

On 01/02/2013 04:01 AM, Nobody wrote:

On Wed, 02 Jan 2013 00:49:36 +0100, someone wrote:


In [11]: del format
---
NameError Traceback (most recent call last)
ipython-input-11-028e6ffb84a8 in module()
 1 del format

NameError: name 'format' is not defined


What does this mean? Why does it say 'format cannot be deleted after I
did the wildcard import ?


You can't delete built-in names.


Ah, ok - and cannot overwrite it too, I guess... A shame that pylint 
didn't knew about this.



It has nothing to do with the wildcard import. The PyOpenGL modules delete
format from the module's variables as soon as they are finished with
it, so the set of names created by the wildcard import doesn't include
format.


Ok, sounds to me like I can safely ignore this pylint warning in any 
case... Thanks!



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


Re: how to solve complex equation?

2013-01-01 Thread someone

On 01/01/2013 10:49 PM, Jens Thoms Toerring wrote:

Usama Khan usamazo...@gmail.com wrote:

how to solve complex equation in pyhton? and then use it to make a program.
. i have created new post as my last post is i guessed ranked as a cheater.
.:(



i know very litle about python as well as programing. .



which equation am taliking u will be thinking. . i am giving u the link
kindly c that equation. . n kindly let me know the way. .



https://groups.google.com/forum/?fromgroups=#!topic/comp.lang.python/cxG7DLxXgmo


First of all, the equation given there is unusable (even the number
of parentheses doesn't match up). Propbably it's meant to be the
one someone else posted a link to:

http://classes.engr.oregonstate.edu/cce/winter2012/ce492/Modules/06_structural_design/06-3_body.htm

This thingy can't be solved on paper so you need some iterative
algorithm to find the solution. So waht you do is modify the equa-
tion so that you have 0 on one side and then consider the other
side to be a function of SN+1. Now the problem you're left with
is to find the value(s) of SN+1 (and thus of SN) where the func-
tion has a zero-crossing. A commonly use algorithms for finding
zero-crossings is Newton's method. You can find lots of sites on
the internet describing it in all neccessary detail. It boils
down to start with some guess for the result and then calculate
the next, better approximation via

   xn+1 = xn - f(xn) / f'(xn)

where f(xn)n) is the value of the function at point xn and
f'(xn) the value of the derivative of f (with respect to x)
also at xn. You repeat the process until the difference be-
tween xn an the next, better approximation, xn+1, has become
as small as you need it.

So it's very simple to implement and the ugliest bit is pro-
bably calculating the required derivative of the function with
respect to SN+1 (wbich you can take to be x).


Exactly. I think a 5th semester engineering student should know this. If 
not, it's not the python-skills that is the problem. It's the (lack of) 
mathematical insight.


I think maybe the OP should not demand people here to show the 
solution, but begin with something much simpler and then as he becomes 
better and better with python, he can move towards more programmatically 
advanced code.


The basic idea about an iterating loop, defining an objective function 
etc is not really advanced python.


But I think the OP should start out with something more simple than what 
he tries to do here.


Just starting out by iteratingly finding the solution to x^2-9 = 0 is a 
great starting place.


After having studied, googled python examples on the internet, I think 
most people should be able to solve x^2-9=0 in a day for a guy who knows 
about programming in an arbitrary programming language other than python.


It looks like laziness, when we don't see any attempts to show what has 
been tried to do, from the OP's point of view.


The best way to get good feedback (IMHO) is to post some code and then 
post any errors/warnings that python is giving back.


Don't just write: Give me the code for doing this.

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


Re: numpy has got newtonsmethod?

2013-01-01 Thread Chris Angelico
On Wed, Jan 2, 2013 at 11:34 AM, Usama Khan usamazo...@gmail.com wrote:
 yeah i have read it sir CrisA. .:)

 thanks . .:)

 i wish i could make u watch my google search list of last two days nd idm 
 downlaodng list of last two days. .text me ur email id. .i can show u my 
 efforts. .
 :)

Well, my email id (I presume you mean email address) is perfectly
visible in the headers of all my posts to this list/newsgroup. But
that doesn't give you the right to email me a list of everything
you've searched for, downloaded, etc. Plus, it wouldn't help your
case; your posts carry no indication that you have learned from your
web searches, so it doesn't matter what you've done. Your posts also
bear no suggestion that you have read esr's excellent article on
asking questions, which is why I reiterated it.

So don't show me your efforts. Show me that you've learned from them.

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


Re: Noob: Trying to run two python scrips on a pfsense/freeBSD for the OWL-Intuition-LC

2013-01-01 Thread wrw
On Jan 1, 2013, at 9:42 PM, vbho...@gmail.com wrote:

 Hi,
 
 I wrote couple of scrips to work with OWL-intution-LC home/office electricity 
 monitor. The concept of the first scrip (owl.py) to capture network multicast 
 from the OWL gateway and write to a .csv file has been taken from a 
 raspberrypi forum and further developed upon to work with sqlite. The second 
 scrip (responder.py)keeps checking a mail account for any email queries 
 received and responds with a detailed electricity report to the sender. 
 
 I've been using owl.py since some days  works fine on the pfsense/freebsd, 
 it has been set to start on boot using shellcmd. The second scrip also works 
 when I execute manually from the shell, but it does not seems to start upon 
 boot how I did for owl.py. I cannot find anything in /var/log/system.log 
 about execution or failure of either scrips.
 
 This question may not exactly relate with python but any help would be 
 appreciated.
 
 Another Q I wanted to ask or rather confirm, I think python does not log 
 anything from scrip runtime/termination and that there is a log library that 
 needs to be used. I find using the log library adding bulk to the code and 
 for every line I suspect of failure in the code I would need to put in an 
 exception to create log ? Is there a better way of logging where it just logs 
 the reason on scrip termination ? I just want to log the msg it shows when 
 manually run in a shell. - Thanks.
 -- 
 http://mail.python.org/mailman/listinfo/python-list

Can't help with the mail script's failure to launch (although it may be because 
something in the script requires an environmental variable that hasn't been 
created when running in batch).  But I can make a suggestion for logging.  
Operating systems have subtle differences, so this may not be a solution for 
you, but at least on OS-X (which at its heart is an amalgam of freebsd and 
netbsd), any print statement goes to the system log if the program is being run 
from batch rather than from an interactive terminal window.  Thus, simple print 
statements scattered through the code should allow you to monitor the execution 
under normal circumstances.  Of course, any abnormal termination will result in 
error messages in the same system log.

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


Re: Handling Special characters in python

2013-01-01 Thread anilkumar . dannina
On Wednesday, January 2, 2013 12:00:06 AM UTC+5:30, Chris Rebert wrote:
 On Jan 1, 2013 3:41 AM, anilkuma...@gmail.com wrote:
 
 
 
  I am facing one issue in my module. I am gathering data from sql server 
  database. In the data that I got from db contains special characters like 
  endash. Python was taking it as \x96. I require the same 
  character(endash). How can I perform that. Can you please help me in 
  resolving this issue.
 
 
 1. What library are you using to access the database?
 
 2. To confirm, it's a Microsoft SQL Server database?
 
 3. What OS are you on?



1. I am using pymssql module to access the database.
2. Yes, It is a SQL server database.
3. I am on Ubuntu 11.10
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: New to python, do I need an IDE or is vim still good enough?

2013-01-01 Thread Ramchandra Apte
On Friday, 28 December 2012 01:31:16 UTC+5:30, mogul  wrote:
 'Aloha!
 
 
 
 I'm new to python, got 10-20 years perl and C experience, all gained on unix 
 alike machines hacking happily in vi, and later on in vim.
 
 
 
 Now it's python, and currently mainly on my kubuntu desktop.
 
 
 
 Do I really need a real IDE, as the windows guys around me say I do, or will 
 vim, git, make and other standalone tools make it the next 20 years too for 
 me? 
 
 
 
 Oh, by the way, after 7 days I'm completely in love with this python thing. I 
 should have made the switch much earlier!
 
 
 
 /mogul %-)

I use Eclipse only because it has PEP 8 and Pylint integration.
Ezio Melotti, core Python developer, said in personal chat, that he uses Kate.
IDEs aren't that useful when coding in Python.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: got stuck in equation

2013-01-01 Thread Ramchandra Apte
On Tuesday, 1 January 2013 22:55:21 UTC+5:30, Usama Khan  wrote:
 am just a begginer bro. . jus learnt if elif while nd for loop. . 
 
 
 
 can u just display me the coding u want. .it could save my time that i have 
 while searchning SN out. . i will give u that dependable variables values. .
 
 
 
 nd SN range 4 inches to 13.5 inches
 
 
 
 log(w18)=50x10^6
 
 Z=-1.645
 
 S=0.45
 
 dpsi=2.5
 
 Mr=5800
 
 
 
 now can u give me the coding of this equation as i need to save my time. . .i 
 am learning from tutorials. . so its taking lot of time. kindly consider my 
 request nd give me the code so that i can put it. .i dont want to losen up my 
 grade. .am trying hard. . .
 
 
 
 Regards

If you spend half a minute extra to write your sentences properly and not use 
SMS abbreviations, then it would save totally many minutes of other people's 
time. 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Noob: Trying to run two python scrips on a pfsense/freeBSD for the OWL-Intuition-LC

2013-01-01 Thread Vineet Bhojnagarwala
I've print statements in my code for troubleshooting purpose, but I do not find 
it in any of the logs in /var/log/, not even system.log. Anything that I need 
to do for it to write the log ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Handling Special characters in python

2013-01-01 Thread Chris Rebert
On Jan 1, 2013 8:48 PM, anilkumar.dann...@gmail.com wrote:
 On Wednesday, January 2, 2013 12:00:06 AM UTC+5:30, Chris Rebert wrote:
  On Jan 1, 2013 3:41 AM, anilkuma...@gmail.com wrote:
 
   I am facing one issue in my module. I am gathering data from sql
server database. In the data that I got from db contains special characters
like endash. Python was taking it as \x96. I require the same
character(endash). How can I perform that. Can you please help me in
resolving this issue.
 
  1. What library are you using to access the database?
  2. To confirm, it's a Microsoft SQL Server database?
  3. What OS are you on?

 1. I am using pymssql module to access the database.
 2. Yes, It is a SQL server database.
 3. I am on Ubuntu 11.10

Did you set client charset (to UTF-8, unless you have good reason to
choose otherwise) in freetds.conf? That should at least ensure that the
driver itself is exchanging bytestrings via a well-defined encoding.
If you want to work in Unicode natively (Recommended), you'll probably need
to ensure that the columns are of type NVARCHAR as opposed to VARCHAR.
Unless you're using SQLAlchemy or similar (which I personally would
recommend using), you may need to do the .encode() and .decode()-ing
manually, using the charset you specified in freetds.conf.

Sorry my advice is a tad general. I went the alternative route of
SQLAlchemy + PyODBC + Microsoft's SQL Server ODBC driver for Linux (
http://www.microsoft.com/en-us/download/details.aspx?id=28160 ) for my
current project, which likewise needs to fetch data from MS SQL to an
Ubuntu box. The driver is intended for Red Hat and isn't packaged nicely
(it installs via a shell script), but after that was dealt with, things
have gone smoothly. Unicode, in particular, seems to work properly.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pygame - importing GL - very bad...

2013-01-01 Thread Steven D'Aprano
On Wed, 02 Jan 2013 00:49:36 +0100, someone wrote:

 On 01/01/2013 12:49 PM, Steven D'Aprano wrote:
   On Tue, 01 Jan 2013 12:00:32 +0100, someone wrote:
  
   See this code (understand why I commented out first line):
  
   # from OpenGL.GL import *
   [...]
   The reason why I commented out the first line is that I use pylint
   and it reports: [W] Redefining built-in 'format' for this line.
  
   From: http://www.logilab.org/card/pylintfeatures tell: W0621:
   Redefining name %r from outer scope (line %s) Used when a variable's
   name hide a name defined in the outer scope.
  
   I don't like to redefine already defined names so therefore I had to
   outcomment first line and then keep on adding stuff until I could
   run my program... But this SUCKS! I can see that pygame hasn't been
   updated for a long while - not many users use it? I'm not very happy
   about this...
  
   from pygame import *
   del format
 
 Are you sure about this? Because I'm not (OTOH I'm maybe not as
 experienced in python as some of you)...

In the general case of deleting global names that shadow builtin names, 
yes I am.

In the specific case of importing * from pygame, no. I trusted you that 
pygame exports format. Unfortunately, it seems that you were fooled by an 
invalid warning from pylint, so we were both mistaken.


 Ipython log:
 
 
 In [6]: test=format(43)
 In [7]: type(test)
 Out[7]: str
 In [8]: from pygame import *
 In [9]: test=format(43)
 In [10]: type(test)
 Out[10]: str
 In [11]: del format
 
 NameError  Traceback (most recent call last)
 ipython-input-11-028e6ffb84a8 in module() 
  1 del format
 
 NameError: name 'format' is not defined 
 
 
 What does this mean? Why does it say 'format cannot be deleted after I
 did the wildcard import ?

It means that there is no format in the current scope, which implies 
that pygame no longer has a format which can be imported.

You don't need an import to shadow built-ins. See for example:

py format
built-in function format
py format = NOBODY expects the Spanish Inquisition!
py format  # this shadows the built-in format
'NOBODY expects the Spanish Inquisition!'
py del format  # get rid of the Spanish Inquisition
py format 
built-in function format
py del format
Traceback (most recent call last):
  File stdin, line 1, in module
NameError: name 'format' is not defined


When a name is not discovered in the current scope, the builtin scope is 
checked before Python gives up and reports a NameError. But del only 
works on the current scope, to stop you from accidentally deleting the 
wrong object.


   pylint may still complain, but you can ignore it. By deleting the
   name format, that will unshadow the builtin format.
 
 Are you sure?

Since it turns out that pylint was actually wrong to complain, no format 
was actually imported, then yes you can safely ignore it :-)



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


[issue16832] Expose cache validity checking support in ABCMeta

2013-01-01 Thread Daniel Urban

Changes by Daniel Urban urban.dani...@gmail.com:


--
nosy: +daniel.urban

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



[issue11939] Implement stat.st_dev and os.path.samefile on windows

2013-01-01 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

 New changeset 3738d270c54a by Brian Curtin in branch 'default':
 st_dev/st_rdev should be unsigned long as dwVolumeSerialNumber, which it is
 set to, is a DWORD. This was fixed in #11939 and the overflow was
 mentioned in #10657 and seen by me on some machines.
 http://hg.python.org/cpython/rev/3738d270c54a

But than st_dev used as long in _pystat_fromstructstat(). Perhaps you should 
check if st_dev is negative and then select 
PyLong_FromLong/PyLong_FromLongLong or 
PyLong_FromUnsignedLong/PyLong_FromUnsignedLongLong.

--

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



[issue16833] httpc.lient delayed ack / Nagle algorithm optimisation performs badly for large messages

2013-01-01 Thread Benno Leslie

New submission from Benno Leslie:

he http.client HTTPConnection._send_output method has an optimization for 
avoiding bad interactions between delayed-ack and the Nagle algorithm:

http://hg.python.org/cpython/file/f32f67d26035/Lib/http/client.py#l884

Unfortunately this interacts rather poorly if the case where the message_body 
is a bytes instance and is rather large.

If the message_body is bytes it is appended to the headers, which causes a copy 
of the data. When message_body is large this duplication of data can cause a 
significant spike in memory usage.

(In my particular case I was uploading a 200MB file to 30 hosts at the same 
leading to memory spikes over 6GB.

[There is a short thread discussing this issue on python-dev; Subject: 
http.client Nagle/delayed-ack optimization; Date: Dec 15, 2012]

--
components: Library (Lib)
files: http_opt.diff
keywords: patch
messages: 178728
nosy: bennoleslie
priority: normal
severity: normal
status: open
title: httpc.lient delayed ack / Nagle algorithm optimisation performs badly 
for large messages
type: performance
versions: Python 3.3
Added file: http://bugs.python.org/file28518/http_opt.diff

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



[issue16809] Tk 8.6.0 introduces TypeError. (Tk 8.5.13 works)

2013-01-01 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I don't install Tcl/Tk 8.6 yet, but looks as pack info call returns a new 
type of Tcl data (perhaps DictType) which doesn't detected in FromObj().

--

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



[issue16830] Add skip_host and skip_accept_encoding to httplib/http.client

2013-01-01 Thread Antoine Pitrou

Antoine Pitrou added the comment:

I'm not sure this is a desirable feature in the stdlib, but regardless, your 
solution isn't very scalable: a new argument will have to be added each time 
someone wants to avoid sending a given header.

Another possibility would be to allow passing None in values of the `headers` 
dict, in which case the given header wouldn't be send at all.

--
nosy: +orsenthil, pitrou

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



[issue16833] httpc.lient delayed ack / Nagle algorithm optimisation performs badly for large messages

2013-01-01 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Thanks for the patch. Perhaps our MSS value should be an upper bound of common 
values? Apparently for a localhost connection TCP_MAXSEG gives 16384 here (but 
I don't know if the http.client optimization is important for localhost 
connections).

Also, it would be nice to add an unit test in Lib/test/test_httplib.py.

--
nosy: +neologix, pitrou
stage:  - patch review
versions: +Python 3.4 -Python 3.3

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



[issue16828] bz2 error on compression of empty string

2013-01-01 Thread Antoine Pitrou

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


--
priority: normal - high

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



[issue16834] ioctl mutate_flag behavior in regard to the buffer size limit

2013-01-01 Thread Yuval Weinbaum

New submission from Yuval Weinbaum:

In fcntl module, the documentation states the following regarding the 
mutate_flag in ioctl method:

***
If it is false, the buffer’s mutability is ignored and behaviour is as for a 
read-only buffer, except that the 1024 byte limit mentioned above is avoided – 
so long as the buffer you pass is as least as long as what the operating system 
wants to put there, things should work.
***

However, looking at the code (fcntlmodule.c) it seems that the 1024 bytes 
limitation is avoided when the mutate_flag is set to True (the opposite of what 
is stated in the doc).

--
assignee: docs@python
components: Documentation
messages: 178732
nosy: Yuval.Weinbaum, docs@python
priority: normal
severity: normal
status: open
title: ioctl mutate_flag behavior in regard to the buffer size limit
versions: Python 2.6

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



[issue16833] httpc.lient delayed ack / Nagle algorithm optimisation performs badly for large messages

2013-01-01 Thread Charles-François Natali

Charles-François Natali added the comment:

 Thanks for the patch. Perhaps our MSS value should be an upper bound of 
 common values? Apparently for a localhost connection TCP_MAXSEG gives 16384 
 here (but I don't know if the http.client optimization is important for 
 localhost connections).

According to http://en.wikipedia.org/wiki/Maximum_transmission_unit,
the MTU (from which the MSS is derived) for a wireless NIC is around
8000, and you can have jumbo frames on Ethernet up to 9000, so a value
of 2K might be too small (since the goal is to avoid sending a payload
less than MSS with its own send() syscall).
So I think a value like 16K should be OK (the downside to using a
large value is the extra copying, but OTOH it will incur less copying
than now).
Note that the ideal fix for this would be scatter-gather I/O with
sendmsg(): both the header and the payload could be sent in the same
segment, without any extra copying. But I'm not sure it's worth it
here.

A note on the comment:

722 # TCP Maximum Segment Size (MSS) is a TCP stack parameter. There
723 # is no simple and efficient platform independent mechanism for
724 # determining the MSS, so instead a reasonable estimate is chosen.


The MSS is not really a TCP stack parameter (i.e. it's not fixed by
the host like socket buffers, etc): it's usually negociated between
the hosts (and with path MTU discovery or IPv6 it depends on the path
MTU). That's why it's hard to guess ahead of time.

--

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



[issue16787] asyncore.dispatcher_with_send - increase the send buffer size

2013-01-01 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 2eddf7c2efe6 by Charles-François Natali in branch 'default':
Issue #16787: Increase asyncore and asynchat default output buffers size, to
http://hg.python.org/cpython/rev/2eddf7c2efe6

--
nosy: +python-dev

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



[issue16787] asyncore.dispatcher_with_send - increase the send buffer size

2013-01-01 Thread Charles-François Natali

Charles-François Natali added the comment:

Closing!

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

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



[issue16076] xml.etree.ElementTree.Element and xml.etree.ElementTree.TreeBuilder are no longer pickleable

2013-01-01 Thread Eli Bendersky

Eli Bendersky added the comment:

Other thoughts.

I'm not sure why you're surprised the C-Python pickle/unpickle works. You've 
changed the type name from Element to _elementtree.Element, so I would guess 
Python always uses the C version to unpickle as well. Can you debug to verify 
what actually goes on under the hood? Why did you change the class name, by the 
way, I don't think it's a valid change at least for 3.3 in terms of backwards 
compatibility.

Regarding that compatibility, and even easier idea would be for the C pickle to 
return the same __dict__ implicitly gathered from the Python version, and then 
only one version of the unpickle is required.

--

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



[issue16733] Solaris ctypes_test failures

2013-01-01 Thread Meador Inge

Changes by Meador Inge mead...@gmail.com:


--
nosy: +meador.inge

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



[issue16748] Ensure test discovery doesn't break for modules testing C and Python implementations

2013-01-01 Thread Ezio Melotti

Ezio Melotti added the comment:

I just came across the problem described here while reviewing #16694.

The idiom I used for the JSON tests[0] (and possibly a couple of other tests) 
when I rewrote them was to have something like:

class FooTest:
# all the test methods here

class CFooTest(FooTest, unittest.TestCase):
module = c_foo

class PyFooTest(FooTest, unittest.TestCase):
module = py_foo

The reason to only have the subclasses inheriting from unittest.TestCase was 
exactly to avoid having FooTest as a discoverable TestCase.

I think PEP 399 should be updated and the tests should be fixed.
I don't think it's necessary to provide a base class as suggested in the first 
message (it's actually not even necessary to set the module to None, because 
eventually it will be set to either some cmodule or pymodule.  In case 
something goes wrong it's even better if the AttributeError says self has no 
attribute 'module' rather than NoneType has no attribute 'somemeth'.)

@Brett, should I open a separate issue for the PEP 399 changes?

[0] see e.g.: Lib/test/json_tests/test_float.py and 
Lib/test/json_tests/__init__.py (note that here the idiom is a bit more 
complicated, because in addition to set the self.module, I also had to set 
additional attributes and work with different test files in the same package.  
I also added additional tests in __init__ to make sure that import_fresh_module 
worked after adapting it to work with packages.)

--
assignee:  - ezio.melotti

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



[issue9586] warning: comparison between pointer and integer in multiprocessing build on Tiger

2013-01-01 Thread Roundup Robot

Roundup Robot added the comment:

New changeset a5b49db3383d by Richard Oudkerk in branch '3.2':
Issue #9586: Redefine SEM_FAILED on MacOSX to keep compiler happy.
http://hg.python.org/cpython/rev/a5b49db3383d

New changeset a70db584e897 by Richard Oudkerk in branch '3.3':
Issue #9586: Merge
http://hg.python.org/cpython/rev/a70db584e897

New changeset 92990dd91b07 by Richard Oudkerk in branch 'default':
Issue #9586: Merge.
http://hg.python.org/cpython/rev/92990dd91b07

New changeset 395976a1f26f by Richard Oudkerk in branch '2.7':
Issue #9586: Redefine SEM_FAILED on MacOSX to keep compiler happy.
http://hg.python.org/cpython/rev/395976a1f26f

--
nosy: +python-dev

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



[issue11939] Implement stat.st_dev and os.path.samefile on windows

2013-01-01 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 61bada808b34 by Brian Curtin in branch 'default':
Set st_dev on Windows as unsigned long to match its DWORD type, related to the 
change to fix #11939.
http://hg.python.org/cpython/rev/61bada808b34

--

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



[issue11939] Implement stat.st_dev and os.path.samefile on windows

2013-01-01 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Now the code is wrong on non-Windows without PY_LONG_LONG and with signed 
st_dev.

--

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



[issue16830] Add skip_host and skip_accept_encoding to httplib/http.client

2013-01-01 Thread Bryan Bishop

Bryan Bishop added the comment:

On Tue, Jan 1, 2013 at 5:41 AM, Antoine Pitrou wrote:
 Another possibility would be to allow passing None in values of the `headers` 
 dict, in which case the given header wouldn't be send at all.

I agree that your solution is more scaling-friendly than the patch I originally 
submitted. But from another perspective, consider how alien it is to have to 
explicitly add keys set to None in the headers to get desired behavior.

Maybe there could be a single flag strict (or possibly a better name) that 
would indicate that the dict is in fact what I want to send and that it should 
not be modified? Or perhaps there should be base_headers list (not a 
dictionary) of header keys of which defaults to not inject?

Also, would making {Accept-Encoding: None} send no Accept-Encoding header 
be backwards incompatible with the current behavior?

--

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



[issue11939] Implement stat.st_dev and os.path.samefile on windows

2013-01-01 Thread Brian Curtin

Brian Curtin added the comment:

Backed out the changeset. If you have a solution, feel free to fix it.

--

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



[issue16830] Add skip_host and skip_accept_encoding to httplib/http.client

2013-01-01 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 On Tue, Jan 1, 2013 at 5:41 AM, Antoine Pitrou wrote:
  Another possibility would be to allow passing None in values of the
 `headers` dict, in which case the given header wouldn't be send at
 all.
 
 I agree that your solution is more scaling-friendly than the patch I
 originally submitted. But from another perspective, consider how alien
 it is to have to explicitly add keys set to None in the headers to get
 desired behavior.

Well, that is not a common need, is it?
That said, we could indeed have a separate argument omit_headers
listing the headers that we don't want to send.

--

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



[issue16819] IDLE b method completion incorrect

2013-01-01 Thread Senthil Kumaran

Senthil Kumaran added the comment:

The patch seems good to me. Please commit it.

--
nosy: +orsenthil

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



[issue16076] xml.etree.ElementTree.Element and xml.etree.ElementTree.TreeBuilder are no longer pickleable

2013-01-01 Thread Stefan Krah

Stefan Krah added the comment:

Yes, currently the C version is also used for unpickling. Actually
this problem was one of the reasons why _decimal sets its name to
decimal.
 


from test.support import import_fresh_module
import pickle, sys

C = import_fresh_module('xml.etree.ElementTree', fresh=['_elementtree'])
P = import_fresh_module('xml.etree.ElementTree', blocked=['_elementtree'])
e = C.Element('foo', bar=42)
e.text = text goes here
e.tail = opposite of head
C.SubElement(e, 'child').append(C.Element('grandchild'))
e.append(C.Element('child'))
e.findall('.//grandchild')[0].set('attr', 'other value')
sys.modules['xml.etree.ElementTree'] = C 
s = pickle.dumps(e)
s

b'\x80\x03c_elementtree\nElement\nq\x00X\x03\x00\x00\x00fooq\x01}q\x02X\x03\x00\x00\x00barq\x03K*s\x86q\x04Rq\x05X
\x0e\x00\x00\x00text goes hereq\x06X\x10\x00\x00\x00opposite of 
headq\x07h\x00X\x05\x00\x00\x00childq\x08\x85q\tRq
\nNNh\x00X\n\x00\x00\x00grandchildq\x0b}q\x0cX\x04\x00\x00\x00attrq\rX\x0b\x00\x00\x00other
 valueq\x0es\x86q\x0fRq
\x10NNN\x87q\x11b\x85q\x12\x87q\x13bh\x00h\x08\x85q\x14Rq\x15NNN\x87q\x16b\x86q\x17\x87q\x18b.'

sys.modules['xml.etree.ElementTree'] = P
x = pickle.loads(s)
type(x)
class '_elementtree.Element'

--
nosy: +skrah

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



[issue16747] Remove 'file' type reference from 'iterable' glossary entry

2013-01-01 Thread Senthil Kumaran

Senthil Kumaran added the comment:

Hello Zachary, What'wrong with referencing :class:`file` for iterable? I find 
it as OK. Also if it needs to be corrected, the reference could be made for 
:ref:`bltin-file-objects`

Re grammatical fixes, you could point out which were made as with the reflow of 
the text, it is difficult to spot the fix.

--
nosy: +orsenthil

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



[issue16747] Remove 'file' type reference from 'iterable' glossary entry

2013-01-01 Thread R. David Murray

R. David Murray added the comment:

senthil: the file type doesn't exist any more in python3.

--
nosy: +r.david.murray

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



[issue16835] Update PEP 399 to allow for test discovery

2013-01-01 Thread Brett Cannon

New submission from Brett Cannon:

Don't have the base tests inherit from TestCase else they will be discovered by 
unittest and run even though they are not fully defined.

See http://bugs.python.org/issue16748 as the trigger for this issue.

--
messages: 178748
nosy: brett.cannon
priority: normal
severity: normal
status: open
title: Update PEP 399 to allow for test discovery

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



[issue16748] Ensure test discovery doesn't break for modules testing C and Python implementations

2013-01-01 Thread Brett Cannon

Brett Cannon added the comment:

I created http://bugs.python.org/issue16835 to remind me to update PEP 399.

--

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



  1   2   >