Re: New to Python, Help to get script working?

2013-12-15 Thread Mark
On Monday, December 16, 2013 2:48:56 AM UTC-5, Mark wrote:
> On Monday, December 16, 2013 2:43:45 AM UTC-5, Mark wrote:
> 
> > On Monday, December 16, 2013 2:09:38 AM UTC-5, Mark wrote:
> 
> > 
> 
> > > On Sunday, December 15, 2013 9:33:17 PM UTC-5, Chris Angelico wrote:
> 
> > 
> 
> > > 
> 
> > 
> 
> > > > On Mon, Dec 16, 2013 at 12:37 PM, Steven D'Aprano
> 
> > 
> 
> > > 
> 
> > 
> 
> > > > 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > >  wrote:
> 
> > 
> 
> > > 
> 
> > 
> 
> > > > 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > > > Step 1: replace the modified version of the script with a known good 
> > > > > copy.
> 
> > 
> 
> > > 
> 
> > 
> 
> > > > 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > > >
> 
> > 
> 
> > > 
> 
> > 
> 
> > > > 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > > 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > > 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > > Actually, this might be where the problem is, unfortunately. Not the
> 
> > 
> 
> > > 
> 
> > 
> 
> > > > 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > > OP's fault at all. I went and looked at the post linked to, and it has
> 
> > 
> 
> > > 
> 
> > 
> 
> > > > 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > > buggy indentation. (Quite possibly indicates that the author has
> 
> > 
> 
> > > 
> 
> > 
> 
> > > > 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > > two-space tabs, and didn't notice a bug slipping in. I dunno.)
> 
> > 
> 
> > > 
> 
> > 
> 
> > > > 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > > 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > > 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > > Along the way, though, I learned that the script in question is
> 
> > 
> 
> > > 
> 
> > 
> 
> > > > 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > > entirely for generating fake twitch.tv viewers so as to get your
> 
> > 
> 
> > > 
> 
> > 
> 
> > > > 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > > stream highlighted fraudulently, so I'm rather less inclined to help.
> 
> > 
> 
> > > 
> 
> > 
> 
> > > > 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > > Got a legitimate use for this, or are you just trying to cheat your
> 
> > 
> 
> > > 
> 
> > 
> 
> > > > 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > > way to fame?
> 
> > 
> 
> > > 
> 
> > 
> 
> > > > 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > > 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > > 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > > ChrisA
> 
> > 
> 
> > > 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > Thanks for the reply, the answer is yes and no, i already have about 2400 
> > > followers and half mil views, i just wanted to see if i could get it to 
> > > work.
> 
> > 
> 
> > > 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > So after taking everybody's advice, fixed the indentation as mentioned by 
> > > the expert above. :) After, this is what i came up with
> 
> > 
> 
> > > 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > Traceback (most recent call last):
> 
> > 
> 
> > > 
> 
> > 
> 
> > >   File "C:\Python27\Scripts\Twitch.py", line 9, in 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > numberOfViewers = int(sys.argv[1])
> 
> > 
> 
> > > 
> 
> > 
> 
> > > IndexError: list index out of range
> 
> > 
> 
> > > 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > Is this where i would plug in the variables to make it work? I'm not 
> > > quite sure about how you would plug in those numbers
> 
> > 
> 
> > > 
> 
> > 
> 
> > > >>>
> 
> > 
> 
> > 
> 
> > 
> 
> > okay so i kinda get it now, running it in cmd, i use the following command 
> > - 
> 
> > 
> 
> > python twitch.py 10 10. I am running it within the scripts directory.
> 
> > 
> 
> > 
> 
> > 
> 
> > I get the following error in cmd:
> 
> > 
> 
> > 
> 
> > 
> 
> > Syntax Error: invalid syntax
> 
> > 
> 
> > >>>python twitch.py 10 10
> 
> > 
> 
> >File " line 1
> 
> > 
> 
> >  python twitch.py 10 10
> 
> 
> 
> is there a more effecient way of doing this? I just hold shift and right 
> click to run cmd from the folder, 
> 
> 
> 
> File is located in C:\Python27\Scripts

It was my understanding that you need to meet the arguments by running the in 
cmd with the numbers after? I am sorry to show my true noobyness and really 
appreciate the help.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: New to Python, Help to get script working?

2013-12-15 Thread Mark
On Monday, December 16, 2013 2:43:45 AM UTC-5, Mark wrote:
> On Monday, December 16, 2013 2:09:38 AM UTC-5, Mark wrote:
> 
> > On Sunday, December 15, 2013 9:33:17 PM UTC-5, Chris Angelico wrote:
> 
> > 
> 
> > > On Mon, Dec 16, 2013 at 12:37 PM, Steven D'Aprano
> 
> > 
> 
> > > 
> 
> > 
> 
> > >  wrote:
> 
> > 
> 
> > > 
> 
> > 
> 
> > > > Step 1: replace the modified version of the script with a known good 
> > > > copy.
> 
> > 
> 
> > > 
> 
> > 
> 
> > > >
> 
> > 
> 
> > > 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > Actually, this might be where the problem is, unfortunately. Not the
> 
> > 
> 
> > > 
> 
> > 
> 
> > > OP's fault at all. I went and looked at the post linked to, and it has
> 
> > 
> 
> > > 
> 
> > 
> 
> > > buggy indentation. (Quite possibly indicates that the author has
> 
> > 
> 
> > > 
> 
> > 
> 
> > > two-space tabs, and didn't notice a bug slipping in. I dunno.)
> 
> > 
> 
> > > 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > Along the way, though, I learned that the script in question is
> 
> > 
> 
> > > 
> 
> > 
> 
> > > entirely for generating fake twitch.tv viewers so as to get your
> 
> > 
> 
> > > 
> 
> > 
> 
> > > stream highlighted fraudulently, so I'm rather less inclined to help.
> 
> > 
> 
> > > 
> 
> > 
> 
> > > Got a legitimate use for this, or are you just trying to cheat your
> 
> > 
> 
> > > 
> 
> > 
> 
> > > way to fame?
> 
> > 
> 
> > > 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > 
> 
> > 
> 
> > > ChrisA
> 
> > 
> 
> > 
> 
> > 
> 
> > Thanks for the reply, the answer is yes and no, i already have about 2400 
> > followers and half mil views, i just wanted to see if i could get it to 
> > work.
> 
> > 
> 
> > 
> 
> > 
> 
> > So after taking everybody's advice, fixed the indentation as mentioned by 
> > the expert above. :) After, this is what i came up with
> 
> > 
> 
> > 
> 
> > 
> 
> > Traceback (most recent call last):
> 
> > 
> 
> >   File "C:\Python27\Scripts\Twitch.py", line 9, in 
> 
> > 
> 
> > numberOfViewers = int(sys.argv[1])
> 
> > 
> 
> > IndexError: list index out of range
> 
> > 
> 
> > 
> 
> > 
> 
> > Is this where i would plug in the variables to make it work? I'm not quite 
> > sure about how you would plug in those numbers
> 
> > 
> 
> > >>>
> 
> 
> 
> okay so i kinda get it now, running it in cmd, i use the following command - 
> 
> python twitch.py 10 10. I am running it within the scripts directory.
> 
> 
> 
> I get the following error in cmd:
> 
> 
> 
> Syntax Error: invalid syntax
> 
> >>>python twitch.py 10 10
> 
>File " line 1
> 
>  python twitch.py 10 10

is there a more effecient way of doing this? I just hold shift and right click 
to run cmd from the folder, 

File is located in C:\Python27\Scripts
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: New to Python, Help to get script working?

2013-12-15 Thread Chris Angelico
On Mon, Dec 16, 2013 at 6:43 PM, Mark  wrote:
> Syntax Error: invalid syntax
python twitch.py 10 10
>File " line 1
>  python twitch.py 10 10

You're trying to run that from the interactive Python prompt. Run it
from the system - exit Python and run just this script.

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


Re: New to Python, Help to get script working?

2013-12-15 Thread Mark
On Monday, December 16, 2013 2:09:38 AM UTC-5, Mark wrote:
> On Sunday, December 15, 2013 9:33:17 PM UTC-5, Chris Angelico wrote:
> 
> > On Mon, Dec 16, 2013 at 12:37 PM, Steven D'Aprano
> 
> > 
> 
> >  wrote:
> 
> > 
> 
> > > Step 1: replace the modified version of the script with a known good copy.
> 
> > 
> 
> > >
> 
> > 
> 
> > 
> 
> > 
> 
> > Actually, this might be where the problem is, unfortunately. Not the
> 
> > 
> 
> > OP's fault at all. I went and looked at the post linked to, and it has
> 
> > 
> 
> > buggy indentation. (Quite possibly indicates that the author has
> 
> > 
> 
> > two-space tabs, and didn't notice a bug slipping in. I dunno.)
> 
> > 
> 
> > 
> 
> > 
> 
> > Along the way, though, I learned that the script in question is
> 
> > 
> 
> > entirely for generating fake twitch.tv viewers so as to get your
> 
> > 
> 
> > stream highlighted fraudulently, so I'm rather less inclined to help.
> 
> > 
> 
> > Got a legitimate use for this, or are you just trying to cheat your
> 
> > 
> 
> > way to fame?
> 
> > 
> 
> > 
> 
> > 
> 
> > ChrisA
> 
> 
> 
> Thanks for the reply, the answer is yes and no, i already have about 2400 
> followers and half mil views, i just wanted to see if i could get it to work.
> 
> 
> 
> So after taking everybody's advice, fixed the indentation as mentioned by the 
> expert above. :) After, this is what i came up with
> 
> 
> 
> Traceback (most recent call last):
> 
>   File "C:\Python27\Scripts\Twitch.py", line 9, in 
> 
> numberOfViewers = int(sys.argv[1])
> 
> IndexError: list index out of range
> 
> 
> 
> Is this where i would plug in the variables to make it work? I'm not quite 
> sure about how you would plug in those numbers
> 
> >>>

okay so i kinda get it now, running it in cmd, i use the following command - 
python twitch.py 10 10. I am running it within the scripts directory.

I get the following error in cmd:

Syntax Error: invalid syntax
>>>python twitch.py 10 10
   File " line 1
 python twitch.py 10 10
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: New to Python, Help to get script working?

2013-12-15 Thread Chris Angelico
On Mon, Dec 16, 2013 at 6:09 PM, Mark  wrote:
> Traceback (most recent call last):
>   File "C:\Python27\Scripts\Twitch.py", line 9, in 
> numberOfViewers = int(sys.argv[1])
> IndexError: list index out of range
>
> Is this where i would plug in the variables to make it work? I'm not quite 
> sure about how you would plug in those numbers

In Python, sys.argv is the arguments passed to the script. You need to
pass it some arguments when you run it.

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


Re: New to Python, Help to get script working?

2013-12-15 Thread Mark
On Sunday, December 15, 2013 9:33:17 PM UTC-5, Chris Angelico wrote:
> On Mon, Dec 16, 2013 at 12:37 PM, Steven D'Aprano
> 
>  wrote:
> 
> > Step 1: replace the modified version of the script with a known good copy.
> 
> >
> 
> 
> 
> Actually, this might be where the problem is, unfortunately. Not the
> 
> OP's fault at all. I went and looked at the post linked to, and it has
> 
> buggy indentation. (Quite possibly indicates that the author has
> 
> two-space tabs, and didn't notice a bug slipping in. I dunno.)
> 
> 
> 
> Along the way, though, I learned that the script in question is
> 
> entirely for generating fake twitch.tv viewers so as to get your
> 
> stream highlighted fraudulently, so I'm rather less inclined to help.
> 
> Got a legitimate use for this, or are you just trying to cheat your
> 
> way to fame?
> 
> 
> 
> ChrisA

Thanks for the reply, the answer is yes and no, i already have about 2400 
followers and half mil views, i just wanted to see if i could get it to work.

So after taking everybody's advice, fixed the indentation as mentioned by the 
expert above. :) After, this is what i came up with

Traceback (most recent call last):
  File "C:\Python27\Scripts\Twitch.py", line 9, in 
numberOfViewers = int(sys.argv[1])
IndexError: list index out of range

Is this where i would plug in the variables to make it work? I'm not quite sure 
about how you would plug in those numbers
>>> 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Type of an object: ‘obj.__class__’ versus ‘type(obj)’

2013-12-15 Thread Ben Finney
Chris Angelico  writes:

> On Mon, Dec 16, 2013 at 3:50 PM, Ben Finney  
> wrote:
> > Should we expect (ignoring pathological cases) the assertion
> > ‘type(obj) is obj.__class__’ to hold true? If not, under what
> > circumstances would it be sensible for those to differ?
>
> By "pathological cases", do you mean arbitrarily changing
> obj.__class__

By “pathological cases” I mean to acknowledge that, in Python, of course
any attribute or function can be changed merely to thwart some rule
about how those attributes and functions will generally behave — and to
exclude such cases from the question where there is no purpose to the
case other than the thwarting of the general rule.

-- 
 \ “I still have my Christmas Tree. I looked at it today. Sure |
  `\   enough, I couldn't see any forests.” —Steven Wright |
_o__)  |
Ben Finney

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


Need Help with the BeautifulSoup problem, please

2013-12-15 Thread seaspeak
I need to replace all tag  with  after ■. But the result from 
below is '■   D / '
Can you explain what I did wrong, please.

s = '■A B C D / '
soup = BeautifulSoup(s)
for i in soup.find_all(text='■'):
tag = soup.new_tag('span')
tag['style'] = 'REPLACE'
for ii in i.find_next_siblings():
if ii.name=='font' or str(ii).lstrip('')[0:1]=='/':
break
else:
if ii.name=='b':
tag.string=ii.string
print(ii.replace_with(tag))
print(soup)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Type of an object: ‘obj.__class__’ versus ‘type(obj)’

2013-12-15 Thread Devin Jeanpierre
On Sun, Dec 15, 2013 at 8:50 PM, Ben Finney  wrote:
> Should we expect (ignoring pathological cases) the assertion
> ‘type(obj) is obj.__class__’ to hold true? If not, under what
> circumstances would it be sensible for those to differ?

They differ on old-style classes (in 2.x): the type will be either
classobj or instance; and the __class__ doesn't exist (for class
objects) or is what you'd expect (for instances).

This isn't particularly pathological, so I disagree with the
suggestion that one should always definitely use type() for style
reasons.

-- Devin
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Wrapping around a list in Python.

2013-12-15 Thread shengjie . shengjie
On Monday, 16 December 2013 12:38:14 UTC+8, shengjie...@live.com  wrote:
> Hi guys, I am trying to create a fixed list which would allow my values to be 
> wrapped around it.
> 
> For example i have 10 values : 0,1,2,3,4,5,6,7,8,9
> 
> I need to create a list which contains 4 numbers and when the number exceeds 
> the list, it would overwrite the first value.
> 
> [0,1,2,3]
> 
> [4,1,2,3]
> 
> [5,4,1,2]
> 
> 
> 
> Thanks in advance and much help appreciated.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Wrapping around a list in Python.

2013-12-15 Thread shengjie . shengjie
On Monday, 16 December 2013 13:10:22 UTC+8, Gary Herron  wrote:
> On 12/15/2013 08:38 PM, shengjie.sheng...@live.com wrote:
> 
> > Hi guys, I am trying to create a fixed list which would allow my values to 
> > be wrapped around it.
> 
> > For example i have 10 values : 0,1,2,3,4,5,6,7,8,9
> 
> > I need to create a list which contains 4 numbers and when the number 
> > exceeds the list, it would overwrite the first value.
> 
> > [0,1,2,3]
> 
> > [4,1,2,3]
> 
> > [5,4,1,2]
> 
> >
> 
> > Thanks in advance and much help appreciated.
> 
> 
> 
> Is the output really three lists as you show.  Or is that one list whose 
> 
> contents you have shown three snapshots of?  Then what was the point of 
> 
> putting 4 in the first spot when you are just going to move it to the 
> 
> second spot?  And why stop at 4 and 5?  What about 7, 8, and 9?
> 
> 
> 
> Are you really shifting elements onto the beginning of the list and off 
> 
> the end of the list?  (That's easy to do, but is that what you want?)
> 
> 
> 
> If I follow your example a few elements further I get [9,8,7,6], just 
> 
> the last four elements of the original list in reverse order -- so there 
> 
> is no need fill a list and "wrap-around"  -- just grab the last four 
> 
> elements and reverse them.
> 
> 
> 
> Or have I misunderstood the problem completely?  (I think that's 
> 
> likely.)  I'm sure Python is general enough to do what you want, but 
> 
> you'll have to do a much better job telling is what you want.  While you 
> 
> are at it, tell us what you've already done, and how it fails to do 
> 
> whatever it is you want.
> 
> 
> 
> Gary Herron

The idea is to grab the last 4 elements of the array. However i have an array 
that contains a few hundred elements in it. And the values continues to .append 
over time. How would i be able to display the last 4 elements of the array 
under such a condition?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Wrapping around a list in Python.

2013-12-15 Thread Gary Herron

On 12/15/2013 08:38 PM, shengjie.sheng...@live.com wrote:

Hi guys, I am trying to create a fixed list which would allow my values to be 
wrapped around it.
For example i have 10 values : 0,1,2,3,4,5,6,7,8,9
I need to create a list which contains 4 numbers and when the number exceeds 
the list, it would overwrite the first value.
[0,1,2,3]
[4,1,2,3]
[5,4,1,2]

Thanks in advance and much help appreciated.


Is the output really three lists as you show.  Or is that one list whose 
contents you have shown three snapshots of?  Then what was the point of 
putting 4 in the first spot when you are just going to move it to the 
second spot?  And why stop at 4 and 5?  What about 7, 8, and 9?


Are you really shifting elements onto the beginning of the list and off 
the end of the list?  (That's easy to do, but is that what you want?)


If I follow your example a few elements further I get [9,8,7,6], just 
the last four elements of the original list in reverse order -- so there 
is no need fill a list and "wrap-around"  -- just grab the last four 
elements and reverse them.


Or have I misunderstood the problem completely?  (I think that's 
likely.)  I'm sure Python is general enough to do what you want, but 
you'll have to do a much better job telling is what you want.  While you 
are at it, tell us what you've already done, and how it fails to do 
whatever it is you want.


Gary Herron

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


Re: Wrapping around a list in Python.

2013-12-15 Thread shengjie . shengjie
On Monday, 16 December 2013 13:07:46 UTC+8, shengjie...@live.com  wrote:
> On Monday, 16 December 2013 12:59:32 UTC+8, Ben Finney  wrote:
> 
> > shengjie.sheng...@live.com writes:
> 
> > 
> 
> > 
> 
> > 
> 
> > > Hi guys, I am trying to create a fixed list which would allow my
> 
> > 
> 
> > > values to be wrapped around it.
> 
> > 
> 
> > 
> 
> > 
> 
> > This doesn't make a lot of sense to me, but I assume you have a purpose
> 
> > 
> 
> > in mind for this. What is the purpose? Perhaps it will help the
> 
> > 
> 
> > explanation if we know what it's for.
> 
> > 
> 
> > 
> 
> > 
> 
> > > For example i have 10 values : 0,1,2,3,4,5,6,7,8,9
> 
> > 
> 
> > 
> 
> > 
> 
> > Does this mean the input is a list, ‘[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]’? Or
> 
> > 
> 
> > do you mean something else? What is the input?
> 
> > > The input is from [0 to 9] however I want a display which displays [0-3] 
> > > and when the value reaches 3, it replaces the 4th value with the first 
> > > value and so on.
> 
> > 
> 
> > 
> 
> > > I need to create a list which contains 4 numbers and when the number
> 
> > 
> 
> > > exceeds the list, it would overwrite the first value.
> 
> > 
> 
> > 
> 
> > 
> 
> > > [0,1,2,3]
> 
> > 
> 
> > > [4,1,2,3]
> 
> > 
> 
> > > [5,4,1,2]
> 
> > 
> 
> > 
> 
> > 
> 
> > That's three different lists. What is the input in each case? Under what
> 
> > 
> 
> > circumstances would you expect each one to be produced?
> 
> > 
> 
> > 
> 
> > 
> 
> > -- 
> 
> > 
> 
> >  \ “As scarce as truth is, the supply has always been in excess of |
> 
> > 
> 
> >   `\   the demand.” —Josh Billings |
> 
> > 
> 
> > _o__)  |
> 
> > 
> 
> > Ben Finney
> 
> 
> 
> Im currently creating a logging function for my GUI in pyqt.
> 
> I saved its feedback data values in a .txt file and I access these values by 
> placing them in a list. However, this list gets really big and I am trying to 
> find a work around.

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


Re: Type of an object: ‘obj.__class__’ versus ‘type(obj)’

2013-12-15 Thread Chris Angelico
On Mon, Dec 16, 2013 at 3:50 PM, Ben Finney  wrote:
> Should we expect (ignoring pathological cases) the assertion
> ‘type(obj) is obj.__class__’ to hold true? If not, under what
> circumstances would it be sensible for those to differ?

By "pathological cases", do you mean arbitrarily changing
obj.__class__, or is there some other way for them to differ?

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


Re: Wrapping around a list in Python.

2013-12-15 Thread shengjie . shengjie
On Monday, 16 December 2013 12:59:32 UTC+8, Ben Finney  wrote:
> shengjie.sheng...@live.com writes:
> 
> 
> 
> > Hi guys, I am trying to create a fixed list which would allow my
> 
> > values to be wrapped around it.
> 
> 
> 
> This doesn't make a lot of sense to me, but I assume you have a purpose
> 
> in mind for this. What is the purpose? Perhaps it will help the
> 
> explanation if we know what it's for.
> 
> 
> 
> > For example i have 10 values : 0,1,2,3,4,5,6,7,8,9
> 
> 
> 
> Does this mean the input is a list, ‘[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]’? Or
> 
> do you mean something else? What is the input?
> 
> 
> 
> > I need to create a list which contains 4 numbers and when the number
> 
> > exceeds the list, it would overwrite the first value.
> 
> 
> 
> > [0,1,2,3]
> 
> > [4,1,2,3]
> 
> > [5,4,1,2]
> 
> 
> 
> That's three different lists. What is the input in each case? Under what
> 
> circumstances would you expect each one to be produced?
> 
> 
> 
> -- 
> 
>  \ “As scarce as truth is, the supply has always been in excess of |
> 
>   `\   the demand.” —Josh Billings |
> 
> _o__)  |
> 
> Ben Finney

Im currently creating a logging function for my GUI in pyqt.
I saved its feedback data values in a .txt file and I access these values by 
placing them in a list. However, this list gets really big and I am trying to 
find a work around.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: GUI:-please answer want to learn GUI programming in python , how should i proceed.

2013-12-15 Thread Chris Angelico
On Mon, Dec 16, 2013 at 3:51 PM, Michael Torrie  wrote:
> I think Python is a great overall application development language,
> especially for the GUI.  First-class functions for callbacks make it
> very nice compared to other languages.  Python  is fast enough for
> full-blown apps too.  Slow parts can be factored out to other languages.

Python is sooo slow when it waits for the human. That pesky
input() function can take *minutes* to return. It's terrible! Factor
that out and your job's done.

And yeah. First-class functions *rock*. ECMAScript is almost there -
not supremely, perhaps, but oh so "all-but"! [1] A function can retain
all sorts of state by being a closure, and yet somehow it doesn't
retain the state of which 'this' (in Python terms, 'self') it should
reference. Why? I don't know. But it's part of the spec now, so
callbacks have to take a function and a context.

var func=document.getElementById;
var foo=func("foo"); /* Won't work */

function funcgen(obj)
{
return function(desc) {return obj.getElementById(desc);}
}
var func=funcgen(document);
var foo=func("foo"); /* Will work! */

In Python, the simple and obvious thing works, because there's less
magic. The incantation "obj.member" followed by the incantation
"callable(args)" has exactly the same meaning as "obj.method(args)".

ChrisA

[1] http://math.boisestate.edu/gas/patience/webop/pat16d.html
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: GUI:-please answer want to learn GUI programming in python , how should i proceed.

2013-12-15 Thread Chris Angelico
On Mon, Dec 16, 2013 at 3:09 PM, Tamer Higazi  wrote:
> I also believe in performance. An application written in C++, can be
> compiled easily on the target platform (like on windows systems) with it's
> native compiler.
> How would it be with wxPython ?!

It's going to spend more than 99% of its time waiting for the user.
Most applications aren't performance-bound. Over the past few years, I
can think of *one* case when my GUI program was actually saturating a
CPU core and I had to dig into a performance fault; the simplistic
design had meant that it would iterate over an entire list of strings
to find which ones it needed to draw, and once that list got huge, the
redraw operation started taking time. But there was no visible problem
except when the app was redrawing itself many times a second in
response to user action AND the set of strings got, as I said, huge.
Every other part of that program, and all of every other GUI
interactive program I've written in recent years, has been coded for
simplicity and not for performance. (This particular example is
actually quite pertinent, as it's the "designated replacement" for a
very similar program written in C++. The C++ one has a tendency to
crash hard if user code does the wrong thing, as there is absolutely
no protection anywhere, while the new code will, at very worst, spew a
traceback and then go back to processing events.)

Of course, performance is a relative thing. If you're running on a PC,
there's no difference at all between taking 1ms and taking 2ms - no
human will notice. But if you're running on a server, that's the
difference between 1000tps and 500tps. And on a phone, that CPU usage
might have an impact on battery life, and running on a tiny PCB the
same coding difference might be the difference between 400ms and
800ms. But in the day-to-day realm of desktop apps, maintainable code
will always be better than marginally faster code.

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


Re: Wrapping around a list in Python.

2013-12-15 Thread Ben Finney
shengjie.sheng...@live.com writes:

> Hi guys, I am trying to create a fixed list which would allow my
> values to be wrapped around it.

This doesn't make a lot of sense to me, but I assume you have a purpose
in mind for this. What is the purpose? Perhaps it will help the
explanation if we know what it's for.

> For example i have 10 values : 0,1,2,3,4,5,6,7,8,9

Does this mean the input is a list, ‘[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]’? Or
do you mean something else? What is the input?

> I need to create a list which contains 4 numbers and when the number
> exceeds the list, it would overwrite the first value.

> [0,1,2,3]
> [4,1,2,3]
> [5,4,1,2]

That's three different lists. What is the input in each case? Under what
circumstances would you expect each one to be produced?

-- 
 \ “As scarce as truth is, the supply has always been in excess of |
  `\   the demand.” —Josh Billings |
_o__)  |
Ben Finney

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


Re: GUI:-please answer want to learn GUI programming in python , how should i proceed.

2013-12-15 Thread Michael Torrie
On 12/15/2013 09:51 PM, Michael Torrie wrote:
> And all modern web apps are a combination of many languages and
> domains, most of which are "compiled" in the traditional sense.

Meant to say, *not* compiled.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: GUI:-please answer want to learn GUI programming in python , how should i proceed.

2013-12-15 Thread Michael Torrie
On 12/15/2013 09:09 PM, Tamer Higazi wrote:
> However, I believe according wxWidgets it would be better coding in the 
> native language the system had been developed.
> The other thing, specially if you would make a customer project, I don't 
> know how to pack the app written in python in an installer. Perhaps I am 
> wrong, and you could give me in exchange an advise ?!

Nonsense.  That's what an installer on windows is for, or what a package
on Linux is for.  There are also ways to bundle up everything you need
to run a Python app in a single exe file.

Ever take a look at the e-book manager, Calibre?  It's 90% Python.  You
can install it on Windows like any other app.  If you're curious as to
how they do things, you can always contact their developers.

> I also believe in performance. An application written in C++, can be 
> compiled easily on the target platform (like on windows systems) with 
> it's native compiler.
> How would it be with wxPython ?!

It would probably perform just fine.  Anything that can't get enough
speed to run in Python can easily be delegated to native libraries or
subroutines.

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


Re: GUI:-please answer want to learn GUI programming in python , how should i proceed.

2013-12-15 Thread Michael Torrie
On 12/15/2013 05:34 PM, Tamer Higazi wrote:
> For wxPython there is a good book.
> You will feel convinient.
> 
> 
> But to be honest, I don't believe that Python is the best choice for GUI 
> development, but it's only an opinion.
> Otherwise I would advise you going into C++ and code with wxWidgets.

Perhaps this is because the wx binding in Python is too C++-like and
lacks python concepts and idioms?  Or are you saying Python in general
is not a good language for GUI development?

GUI design is moving firmly into the realm of interpreted or
non-compiled languages, with compiled languages often doing the real
back end work.  For example Firefox implements its entire GUI in
Javascript using XML GUI definitions.  This all drives a C-based
rendering engine.  Also Qt 5 emphasizes developing GUIs using QtQuick,
which is also Javascript-based with XML and CSS for styling.  And all
modern web apps are a combination of many languages and domains, most of
which are "compiled" in the traditional sense.

I think Python is a great overall application development language,
especially for the GUI.  First-class functions for callbacks make it
very nice compared to other languages.  Python  is fast enough for
full-blown apps too.  Slow parts can be factored out to other languages.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Type of an object: ‘obj.__class__’ versus ‘type(obj)’

2013-12-15 Thread Ben Finney
Ned Batchelder  writes:

> Generally, my answer would be, "You probably don't need the type as
> much as you think you do."  
> […]
> Also, don't overlook isinstance().

Agreed.

> But when you do need it, type(x) is better than x.__class__, simply
> because we should always favor builtin functions over direct access of
> dunder-names where possible.

Thanks.

Should we expect (ignoring pathological cases) the assertion
‘type(obj) is obj.__class__’ to hold true? If not, under what
circumstances would it be sensible for those to differ?

-- 
 \   “For fast acting relief, try slowing down.” —Jane Wagner, via |
  `\   Lily Tomlin |
_o__)  |
Ben Finney

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


Re: GUI:-please answer want to learn GUI programming in python , how should i proceed.

2013-12-15 Thread Tamer Higazi

Hi Mark!

It is an advise, in which language somebody wants to code is of course 
everybodys free choice.


However, I believe according wxWidgets it would be better coding in the 
native language the system had been developed.
The other thing, specially if you would make a customer project, I don't 
know how to pack the app written in python in an installer. Perhaps I am 
wrong, and you could give me in exchange an advise ?!


I also believe in performance. An application written in C++, can be 
compiled easily on the target platform (like on windows systems) with 
it's native compiler.

How would it be with wxPython ?!


Thanks for your response



Tamer

On 16.12.2013 03:18, Mark Lawrence wrote:

On 16/12/2013 00:34, Tamer Higazi wrote:


But to be honest, I don't believe that Python is the best choice for GUI
development, but it's only an opinion.
Otherwise I would advise you going into C++ and code with wxWidgets.

Tamer



Can you state why you prefer C++ and wxWidgets over Python and 
wxPython, which wraps wxWidgets?




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


Wrapping around a list in Python.

2013-12-15 Thread shengjie . shengjie
Hi guys, I am trying to create a fixed list which would allow my values to be 
wrapped around it.
For example i have 10 values : 0,1,2,3,4,5,6,7,8,9
I need to create a list which contains 4 numbers and when the number exceeds 
the list, it would overwrite the first value.
[0,1,2,3]
[4,1,2,3]
[5,4,1,2]

Thanks in advance and much help appreciated.
-- 
https://mail.python.org/mailman/listinfo/python-list


Want guidance to set proxy please help

2013-12-15 Thread Jai
hey i am working on parsing like  project . 

so , i need some step to  set proxy 
so that my ip is not blocked by them 

+=
i am using this method 


proxy_support = urllib2.ProxyHandler({"http":"http://61.147.82.87:8000"})
opener = urllib2.build_opener(proxy_support)
urllib2.install_opener(opener)


is it ok ? if yes 
how can i verify that my  i have set proxy 
if no, please give some guidance
also if some modification need please help 

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


Re: Eliminate "extra" variable

2013-12-15 Thread Igor Korot
Hi,
I have the same result even with:

sqlite3.connect(r'...')

Any other alternatives?

Thank you.


On Sun, Dec 15, 2013 at 4:58 PM, MRAB  wrote:
> On 15/12/2013 22:46, Igor Korot wrote:
>>
>> Tim,
>>
>> On Sun, Dec 15, 2013 at 4:29 AM, Tim Chase
>>  wrote:
>>>
>>> On 2013-12-15 06:17, Tim Chase wrote:
>
> conn = sqlite3.connect('x.sqlite',
>>
>> ... detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)


 Your example code omitted this one crucial line.  Do you specify the
 detect_types parameter to connect()?
>>
>>
>> Yes, I did.
>> This is the beginning of the session:
>>
> import sqlite3
> conn = sqlite3.connect('c:\Documents and
> Settings\Igor.FORDANWORK\Desktop\mydb.db', detect_types =
> sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)
>>
>>
> When writing paths on Windows, it's a good idea to use raw string
> literals or slashes instead of backslashes:
>
> conn = sqlite3.connect(r'c:\Documents and
> Settings\Igor.FORDANWORK\Desktop\mydb.db', detect_types =
> sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)
>
> or:
>
> conn = sqlite3.connect('c:/Documents and
> Settings/Igor.FORDANWORK/Desktop/mydb.db', detect_types =
> sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)
>
>
>> Also please note that you session was missing the cursor creation command.
>> ;-)
>>
>> Thank you.
>>
>>>
>>> It's really the PARSE_DECLTYPES that is important.
>>>
>>> http://docs.python.org/2/library/sqlite3.html#sqlite3.PARSE_DECLTYPES
>>>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: a question about list as an element in a tuple

2013-12-15 Thread rusi
On Monday, December 16, 2013 9:27:11 AM UTC+5:30, Chris Angelico wrote:
> On Mon, Dec 16, 2013 at 2:30 PM, liuerfire Wang  wrote:
> > TypeError: 'tuple' object does not support item assignment
> > In [5]: a
> > Out[5]: ([1, 1], [])
> > no problem, there is an exception. But a is still changed.
> > is this a bug, or could anyone explain it?

> It's not a bug, but it's a bit confusing. Here's what happens. The
> augmented assignment operator += triggers an in-place addition (where
> possible; for lists, it's possible), so the original list will be
> changed:

> >>> a = [1]
> >>> b = a
> >>> a += [2]
> >>> b
> [1, 2]

> Whereas using separate assignment and addition creates a new list:

> >>> a = a + [3]
> >>> a
> [1, 2, 3]
> >>> b
> [1, 2]

> To handle both mutable types (like list) and immutable ones (like
> str), the augmented assignment operators have to be able to choose
> whether or not they change their object:

> >>> a = "1"
> >>> b = a
> >>> a += "2"
> >>> b
> '1'
> >>> a
> '12'

> So what happens under the hood is, more or less:

> a += [2]
> # ... is equivalent to ...
> a = a.__iadd__([2])

> Which can be explored interactively:

> >>> a = [1]
> >>> a.__iadd__([2])
> [1, 2]
> >>> a
> [1, 2]

> The __iadd__ function ("in-place add") returns the new result, and in
> the case of the list, that's done by changing the list. The assignment
> is then done, which does nothing here, but with strings, is the
> critical part of the job. So far, so good.

> Now, when that result gets assigned to the tuple, we have a problem.
> Tuples are immutable - can't change length (no appending), and can't
> assign to elements. So when the final step happens, an exception is
> thrown. At that point, the tuple is complaining "Hey, you can't assign
> to me!", but the list has already done the appending, and it's too
> late to undo that. So the list has changed, and when you go look at
> it, you see the change (since the list is the same whether you find it
> from the tuple or somewhere else), which creates the confusing
> situation of throwing an exception after doing exactly what you
> wanted.

> Python exceptions aren't like SQL errors, causing a rollback of the
> whole transaction. Or, more generally, Python expressions and
> statements aren't transactional. So it's entirely possible, if a
> little confusing, for part of a job to happen. Let's take another
> example that has side effects:

> tup = (1,2,3)
> tup[2] = input("Enter something: ")   # use raw_input() in Python 2

> Tuple assignment can't work... but it's fairly clear that this
> _should_ still show the prompt and wait for the user to type
> something, and only throw the exception later on. It's not as obvious
> in the augmented assignment example, but both are actually doing the
> same thing.

> Hope that helps!

Heh!
Nice question... even nicer explanation!!

I thought I knew that imperative programming is a bad idea:
http://blog.languager.org/2012/11/imperative-programming-lessons-not.html

Never cease to be surprised how bad an idea it is!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: a question about list as an element in a tuple

2013-12-15 Thread Chris Angelico
On Mon, Dec 16, 2013 at 2:30 PM, liuerfire Wang  wrote:
> TypeError: 'tuple' object does not support item assignment
>
> In [5]: a
> Out[5]: ([1, 1], [])
>
> no problem, there is an exception. But a is still changed.
>
> is this a bug, or could anyone explain it?

It's not a bug, but it's a bit confusing. Here's what happens. The
augmented assignment operator += triggers an in-place addition (where
possible; for lists, it's possible), so the original list will be
changed:

>>> a = [1]
>>> b = a
>>> a += [2]
>>> b
[1, 2]

Whereas using separate assignment and addition creates a new list:

>>> a = a + [3]
>>> a
[1, 2, 3]
>>> b
[1, 2]

To handle both mutable types (like list) and immutable ones (like
str), the augmented assignment operators have to be able to choose
whether or not they change their object:

>>> a = "1"
>>> b = a
>>> a += "2"
>>> b
'1'
>>> a
'12'

So what happens under the hood is, more or less:

a += [2]
# ... is equivalent to ...
a = a.__iadd__([2])

Which can be explored interactively:

>>> a = [1]
>>> a.__iadd__([2])
[1, 2]
>>> a
[1, 2]

The __iadd__ function ("in-place add") returns the new result, and in
the case of the list, that's done by changing the list. The assignment
is then done, which does nothing here, but with strings, is the
critical part of the job. So far, so good.

Now, when that result gets assigned to the tuple, we have a problem.
Tuples are immutable - can't change length (no appending), and can't
assign to elements. So when the final step happens, an exception is
thrown. At that point, the tuple is complaining "Hey, you can't assign
to me!", but the list has already done the appending, and it's too
late to undo that. So the list has changed, and when you go look at
it, you see the change (since the list is the same whether you find it
from the tuple or somewhere else), which creates the confusing
situation of throwing an exception after doing exactly what you
wanted.

Python exceptions aren't like SQL errors, causing a rollback of the
whole transaction. Or, more generally, Python expressions and
statements aren't transactional. So it's entirely possible, if a
little confusing, for part of a job to happen. Let's take another
example that has side effects:

tup = (1,2,3)
tup[2] = input("Enter something: ")   # use raw_input() in Python 2

Tuple assignment can't work... but it's fairly clear that this
_should_ still show the prompt and wait for the user to type
something, and only throw the exception later on. It's not as obvious
in the augmented assignment example, but both are actually doing the
same thing.

Hope that helps!

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


a question about list as an element in a tuple

2013-12-15 Thread liuerfire Wang
Just like below:

In [1]: a = ([], [])

In [2]: a[0].append(1)

In [3]: a
Out[3]: ([1], [])

In [4]: a[0] += [1]
---
TypeError Traceback (most recent call last)
 in ()
> 1 a[0] += [1]

TypeError: 'tuple' object does not support item assignment

In [5]: a
Out[5]: ([1, 1], [])

no problem, there is an exception. But a is still changed.

is this a bug, or could anyone explain it?

thanks.


-- 
Best regards.
/**
google+: +liuerfire  twitter:
@liuerfire
蛋疼不蛋疼的都可以试着点一下~^_^~ 
***/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Comparing values of counter in python 3.3

2013-12-15 Thread rusi
On Monday, December 16, 2013 8:10:57 AM UTC+5:30, Roy Smith wrote:
>  rusi  wrote:

> > On Monday, December 16, 2013 7:29:31 AM UTC+5:30, alex23 wrote:
> > > > # Need to compare values of counter and reject in function/routine in 
> > > > value in counter2 is higher then value in counter1 for a current key
> > >  [(k,Counter2[k]) for k in Counter2 - Counter1]
> > Why not just?
> > Counter2 - Counter1
> > And if you want to uncounterify it then
> > dict(Counter2 - Counter1)
> > > Counters are awesome.
> > Yes -- agreed. But 'counter' is a strange name -- after checking whether
> > 'bag' and 'multiset' are there in the library, I would not think to
> > check anything else.

> Bag and multiset are names only CS weenies would think to look for.  
> Counter is the name for the rest of us :-)

Weenie? WEENIE?!? Harrumph! Im offended!! 

More seriously: One issue with all the new good stuff --
comprehensions, generator expressions, dict comprehensions etc is that
the motivations/explanations are all couched imperatively.

So
1.

[something(v) for v in lst]

is understood as
2.

newlst = []
for v in lst:
  newlst.append(something(v))

and so the comprehension is just a one-liner for the for-loop
[Witness Mark's comments earlier that the for loop is more readable]

If instead the comprenension is seen as a programmers equivalent of the
set theory expression

3.

{something(v) | v ∈ lst }  # if the unicode gods deign to allow!

then they would be more easily appreciated and used.

The extreme example of this is that the implementation of
comprehensions were and continue to be wrong because of variable
leakage because 1 is equivalenced to 2 rather than 3.

To come back to the topic: Counter suggesting DO-ing counting
whereas  bag/multiset suggests BE-ing with counts;
ie the one sounds imperative, the other declarative

(which of course may mean its a CS-weenie speaking!)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Eliminate "extra" variable

2013-12-15 Thread Chris Angelico
On Mon, Dec 16, 2013 at 1:43 PM, Igor Korot  wrote:
> So, how do I convert my string to one of those?
> I realized I can just do replace '/' to '\', but is there a better 
> alternative?

The path is exactly the same, whether you use forward slashes or
backslashes, on Windows. Most of the world uses backslashes for
Windows paths, but forward slashes do work fine (and that's not a
Python thing - the underlying APIs work with / just fine too). So you
don't have to actually replace anything.

>>> len(open("c:/Festival2013.txt").read())
79137

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


Re: Eliminate "extra" variable

2013-12-15 Thread Dave Angel
On Sun, 15 Dec 2013 18:43:53 -0800, Igor Korot  
wrote:
On Sun, Dec 15, 2013 at 4:58 PM, MRAB  

wrote:





> When writing paths on Windows, it's a good idea to use raw string
> literals or slashes instead of backslashes:
>
> conn = sqlite3.connect(r'c:\Documents and
> Settings\Igor.FORDANWORK\Desktop\mydb.db', detect_types =
> sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)
>
> or:
>
> conn = sqlite3.connect('c:/Documents and
> Settings/Igor.FORDANWORK/Desktop/mydb.db', detect_types =
> sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)



So, how do I convert my string to one of those?
I realized I can just do replace '/' to '\', but is there a better 

alternative?

The "conversion" is done with a text editor.  The string literals you 
had were just wrong. By the time they have been turned into strings 
it's too late to algorithmically recover your intended string values.


--
DaveA

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


Re: Type of an object: ‘obj.__class__’ versus ‘type(obj)’

2013-12-15 Thread Ned Batchelder

On 12/15/13 8:51 PM, Ben Finney wrote:

Howdy all,

What is the Pythonic way to determine the type of an object? Are there
multiple valid ways, and when should each be used?

We have ‘obj.__class__’, an attribute bound to the object's class. Or is
it? When is that true, and when should we not rely on it?

We have ‘type(obj)’, calling the constructor for the ‘type’ type in
order to get a reference to the type of ‘obj’. Or is it? When is that
true, and when should we not rely on it?

Are there other ways to get at the type of a Python object? What reasons
are there to choose or avoid them?



Generally, my answer would be, "You probably don't need the type as much 
as you think you do."   But when you do need it, type(x) is better than 
x.__class__, simply because we should always favor builtin functions 
over direct access of dunder-names where possible.


Also, don't overlook isinstance().

--
Ned Batchelder, http://nedbatchelder.com

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


Re: Comparing values of counter in python 3.3

2013-12-15 Thread Roy Smith
In article <905d6e7e-6748-42dd-8b63-d80a4d175...@googlegroups.com>,
 rusi  wrote:

> On Monday, December 16, 2013 7:29:31 AM UTC+5:30, alex23 wrote:
> > > # Need to compare values of counter and reject in function/routine in 
> > > value in counter2 is higher then value in counter1 for a current key
> 
> >  [(k,Counter2[k]) for k in Counter2 - Counter1]
> 
> Why not just?
> 
> Counter2 - Counter1
> 
> And if you want to uncounterify it then
> dict(Counter2 - Counter1)
> 
> > Counters are awesome.
> 
> Yes -- agreed. But 'counter' is a strange name -- after checking whether
> 'bag' and 'multiset' are there in the library, I would not think to
> check anything else.

Bag and multiset are names only CS weenies would think to look for.  
Counter is the name for the rest of us :-)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Eliminate "extra" variable

2013-12-15 Thread Igor Korot
Hi,

On Sun, Dec 15, 2013 at 4:58 PM, MRAB  wrote:
> On 15/12/2013 22:46, Igor Korot wrote:
>>
>> Tim,
>>
>> On Sun, Dec 15, 2013 at 4:29 AM, Tim Chase
>>  wrote:
>>>
>>> On 2013-12-15 06:17, Tim Chase wrote:
>
> conn = sqlite3.connect('x.sqlite',
>>
>> ... detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)


 Your example code omitted this one crucial line.  Do you specify the
 detect_types parameter to connect()?
>>
>>
>> Yes, I did.
>> This is the beginning of the session:
>>
> import sqlite3
> conn = sqlite3.connect('c:\Documents and
> Settings\Igor.FORDANWORK\Desktop\mydb.db', detect_types =
> sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)
>>
>>
> When writing paths on Windows, it's a good idea to use raw string
> literals or slashes instead of backslashes:
>
> conn = sqlite3.connect(r'c:\Documents and
> Settings\Igor.FORDANWORK\Desktop\mydb.db', detect_types =
> sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)
>
> or:
>
> conn = sqlite3.connect('c:/Documents and
> Settings/Igor.FORDANWORK/Desktop/mydb.db', detect_types =
> sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)

So, how do I convert my string to one of those?
I realized I can just do replace '/' to '\', but is there a better alternative?

Thank you.


>
>
>> Also please note that you session was missing the cursor creation command.
>> ;-)
>>
>> Thank you.
>>
>>>
>>> It's really the PARSE_DECLTYPES that is important.
>>>
>>> http://docs.python.org/2/library/sqlite3.html#sqlite3.PARSE_DECLTYPES
>>>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Comparing values of counter in python 3.3

2013-12-15 Thread Chris Angelico
On Mon, Dec 16, 2013 at 1:32 PM, rusi  wrote:
> But 'counter' is a strange name -- after checking whether
> 'bag' and 'multiset' are there in the library, I would not think to
> check anything else.

Which is why we have this list. Question: Is there a way to do x, y,
and z, in Python? Answer: Check out this module! *returns time machine
keys to Guido*

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


Re: Comparing values of counter in python 3.3

2013-12-15 Thread rusi
On Monday, December 16, 2013 7:29:31 AM UTC+5:30, alex23 wrote:
> > # Need to compare values of counter and reject in function/routine in value 
> > in counter2 is higher then value in counter1 for a current key

>  [(k,Counter2[k]) for k in Counter2 - Counter1]

Why not just?

Counter2 - Counter1

And if you want to uncounterify it then
dict(Counter2 - Counter1)

> Counters are awesome.

Yes -- agreed. But 'counter' is a strange name -- after checking whether
'bag' and 'multiset' are there in the library, I would not think to
check anything else.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: New to Python, Help to get script working?

2013-12-15 Thread Chris Angelico
On Mon, Dec 16, 2013 at 12:37 PM, Steven D'Aprano
 wrote:
> Step 1: replace the modified version of the script with a known good copy.
>

Actually, this might be where the problem is, unfortunately. Not the
OP's fault at all. I went and looked at the post linked to, and it has
buggy indentation. (Quite possibly indicates that the author has
two-space tabs, and didn't notice a bug slipping in. I dunno.)

Along the way, though, I learned that the script in question is
entirely for generating fake twitch.tv viewers so as to get your
stream highlighted fraudulently, so I'm rather less inclined to help.
Got a legitimate use for this, or are you just trying to cheat your
way to fame?

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


Re: Comparing values of counter in python 3.3

2013-12-15 Thread alex23

On 12/12/2013 5:49 PM, Amjad Syed wrote:

Hello,

I have 2 counters generated from list using  Collections.counter()

I want to print only key,values in Counter2 which have values > then 
corresponding value in Counter1.

E.g
Counter1={97:1,99:2,196:2,198:1}
Counter2={97:1 ,99:3, 196:1,198:1}

# Output
[99,3]
# Need to compare values of counter and reject in function/routine in value in 
counter2 is higher then value in counter1 for a current key


[(k,Counter2[k]) for k in Counter2 - Counter1]

Counters are awesome.
--
https://mail.python.org/mailman/listinfo/python-list


Type of an object: ‘obj.__class__’ versus ‘type(obj)’

2013-12-15 Thread Ben Finney
Howdy all,

What is the Pythonic way to determine the type of an object? Are there
multiple valid ways, and when should each be used?

We have ‘obj.__class__’, an attribute bound to the object's class. Or is
it? When is that true, and when should we not rely on it?

We have ‘type(obj)’, calling the constructor for the ‘type’ type in
order to get a reference to the type of ‘obj’. Or is it? When is that
true, and when should we not rely on it?

Are there other ways to get at the type of a Python object? What reasons
are there to choose or avoid them?

-- 
 \ “Pinky, are you pondering what I'm pondering?” “I think so, |
  `\Brain, but Zero Mostel times anything will still give you Zero |
_o__)  Mostel.” —_Pinky and The Brain_ |
Ben Finney

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


Re: New to Python, Help to get script working?

2013-12-15 Thread Steven D'Aprano
On Sun, 15 Dec 2013 13:31:10 -0800, Mark wrote:

> I originally get an indent error on line 19, i delete the indent and i
> get
> 
> ***'return outside function (Twitch.py, line 19)
> 
> Thats where i am at. This is on version 2.7


Remember the bit where we asked you to copy and paste the entire error 
message, starting from the Traceback line? This is *important*, please do 
not ignore it. If you're going to ask for help from experts, pay 
attention to what the experts tell you.

At this point, I recommend you download the script again, since you've 
been making modifications to it and have probably introduced your own 
errors. Better to start again with a fresh copy in a known good state, 
rather than one that you've been making arbitrary changes to:

Step 1: replace the modified version of the script with a known good copy.

Step 2: try running that script using the correct version of Python.

Step 3: if it fails in some way, copy and paste the entire traceback. It 
may be that you're using it wrongly.



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


Re: GUI:-please answer want to learn GUI programming in python , how should i proceed.

2013-12-15 Thread Mark Lawrence

On 16/12/2013 00:34, Tamer Higazi wrote:


But to be honest, I don't believe that Python is the best choice for GUI
development, but it's only an opinion.
Otherwise I would advise you going into C++ and code with wxWidgets.

Tamer



Can you state why you prefer C++ and wxWidgets over Python and wxPython, 
which wraps wxWidgets?


--
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.


Mark Lawrence

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


Re: GUI:-please answer want to learn GUI programming in python , how should i proceed.

2013-12-15 Thread Tamer Higazi

For wxPython there is a good book.
You will feel convinient.


But to be honest, I don't believe that Python is the best choice for GUI 
development, but it's only an opinion.

Otherwise I would advise you going into C++ and code with wxWidgets.


Tamer


On 14.12.2013 14:12, Jai wrote:

GUI:-want to learn GUI programming in python  , how should i proceed.

There are lots of book here so I am  confuse which book  i should refer so that 
i don't waste time . please answer


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


Re: Eliminate "extra" variable

2013-12-15 Thread MRAB

On 15/12/2013 22:46, Igor Korot wrote:

Tim,

On Sun, Dec 15, 2013 at 4:29 AM, Tim Chase
 wrote:

On 2013-12-15 06:17, Tim Chase wrote:

conn = sqlite3.connect('x.sqlite',

... detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)


Your example code omitted this one crucial line.  Do you specify the
detect_types parameter to connect()?


Yes, I did.
This is the beginning of the session:


import sqlite3
conn = sqlite3.connect('c:\Documents and 
Settings\Igor.FORDANWORK\Desktop\mydb.db', detect_types = 
sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)



When writing paths on Windows, it's a good idea to use raw string
literals or slashes instead of backslashes:

conn = sqlite3.connect(r'c:\Documents and 
Settings\Igor.FORDANWORK\Desktop\mydb.db', detect_types = 
sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)


or:

conn = sqlite3.connect('c:/Documents and 
Settings/Igor.FORDANWORK/Desktop/mydb.db', detect_types = 
sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)



Also please note that you session was missing the cursor creation command. ;-)

Thank you.



It's really the PARSE_DECLTYPES that is important.

http://docs.python.org/2/library/sqlite3.html#sqlite3.PARSE_DECLTYPES



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


Re: Is it more CPU-efficient to read/write config file or read/write sqlite database?

2013-12-15 Thread Tim Chase
On 2013-12-16 10:12, Cameron Simpson wrote:
> On 14Dec2013 10:15, Tim Chase  wrote:
> Annoyingly, sqlite:
> 
>   + only lets one process access the db at a time, taking you back
> to a similar situation as with config files

Is this a Python limitation?  According to the docs[1], it's not a
sqlite limitation (except, as noted, on non-locking filesystems like
NFS)

>   + only lets you access the db from the same thread in which it
> was opened, outstandingly annoying; I've had to gratuitously
> refactor code because of this

I do believe that limitation does hold though depending on the
build-options with which sqlite was compiled [2], though it might be
somewhat different from within Python where the GIL could
possibly prevent actual OS-level-thread issues.

>   + traditionally, sqlite is extreme fsync() happy; forces a disc
> level flush on each commit - extremely slow on busy databases,
> not to mention hard of drives

I'd say this is the right thing for a DB to do.  If it comes back
from a commit() call, it better be on that disk, barring a failure
of the physical hardware.  If it comes back from a commit() and data
gets lost because of a power-failure, something is wrong.

> > * well, except on NFS shares and other places where file-locking
> > is unreliable
> 
> Backing off to config files, making a lock directory is NFS safe.
> So is opening a lock file for write with zero permissions (low level
> open with mode=0).

Interesting.  I haven't used NFS in a long time for anything other
than quick experiments, so it's nice to file this away.  Do you have
a link to some official docs corroborating what you state?

-tkc

[1] http://sqlite.org/faq.html#q5
[2] http://sqlite.org/faq.html#q6





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


Re: Is it more CPU-efficient to read/write config file or read/write sqlite database?

2013-12-15 Thread Chris Angelico
On Mon, Dec 16, 2013 at 10:12 AM, Cameron Simpson  wrote:
>   + traditionally, sqlite is extreme fsync() happy; forces a disc
> level flush on each commit - extremely slow on busy databases,
> not to mention hard of drives

I'd say that's correct behaviour. A commit should be sync'd to disk.
If you don't want it to go to the disk yet, don't commit yet!

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


Re: Is it more CPU-efficient to read/write config file or read/write sqlite database?

2013-12-15 Thread Cameron Simpson
On 14Dec2013 10:15, Tim Chase  wrote:
> On 2013-12-14 07:29, JL wrote:
> > I have a number of python processes which communicate with each
> > other through writing/reading config text files. The python
> > ConfigParser is used. I am wondering if it is more CPU-efficient to
> > switch to using sqlite database instead of using configuration
> > files. If the software does plenty of reading/writing, is it more
> > efficient to use config text files or sqlite database?
> 
> I'm pretty sure that the CPU aspect doesn't really play into things.
> A few thoughts:
> 
> + You'll be I/O bound most of the time.  Even if you used a ramdisk
>   to reduce disk access delays, accessing multiple .txt files requires
>   the OS to do permission-checking each time, while a single sqlite
>   file gets checked once upon opening the DB initially.
> + text-files are fragile unless you take extra pains to keep things
>   atomic
> + sqlite guarantee* atomicity, so you either see all-or-nothing
> + sqlite is also very efficient for querying

Annoyingly, sqlite:

  + only lets one process access the db at a time, taking you back to
a similar situation as with config files

  + only lets you access the db from the same thread in which it
was opened, outstandingly annoying; I've had to gratuitously
refactor code because of this

  + traditionally, sqlite is extreme fsync() happy; forces a disc
level flush on each commit - extremely slow on busy databases,
not to mention hard of drives

> + sticking with plain-text config files is just asking for some sort
>   of race-condition or partial-file issue to come up

A locking mechanism will be required. Lockfiles work quite well.

> + sqlite may give you less CPU load is just an added benefit
> 
> * well, except on NFS shares and other places where file-locking is
>   unreliable

Backing off to config files, making a lock directory is NFS safe.
So is opening a lock file for write with zero permissions (low level
open with mode=0).

Cheers,
-- 
Cameron Simpson 

I drank what?!? - Socrates
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [newbie] trying socket as a replacement for nc

2013-12-15 Thread Chris Angelico
On Mon, Dec 16, 2013 at 9:42 AM, Grant Edwards  wrote:
> Good point -- I meant send().  I keep forgetting that the libc socket
> write() operation is missing in Python and only the send() call has
> been made visible. In C write() and send() are effectively the same
> thing (the parameters are arranged a little differently, but they
> behave identically otherwise).

Mostly - send() lets you set options, write() is equivalent to send()
with no options set. But other than that, they're identical, as stated
in man 2 send.

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


Re: Eliminate "extra" variable

2013-12-15 Thread Igor Korot
Tim,

On Sun, Dec 15, 2013 at 4:29 AM, Tim Chase
 wrote:
> On 2013-12-15 06:17, Tim Chase wrote:
>>> conn = sqlite3.connect('x.sqlite',
... detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)
>>
>> Your example code omitted this one crucial line.  Do you specify the
>> detect_types parameter to connect()?

Yes, I did.
This is the beginning of the session:

>>> import sqlite3
>>> conn = sqlite3.connect('c:\Documents and 
>>> Settings\Igor.FORDANWORK\Desktop\mydb.db', detect_types = 
>>> sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)

Also please note that you session was missing the cursor creation command. ;-)

Thank you.

>
> It's really the PARSE_DECLTYPES that is important.
>
> http://docs.python.org/2/library/sqlite3.html#sqlite3.PARSE_DECLTYPES
>
> -tkc
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [newbie] trying socket as a replacement for nc

2013-12-15 Thread Grant Edwards
On 2013-12-15, Roy Smith  wrote:
> In article ,
>  Grant Edwards  wrote:
>
>> UDP is a a _datagram_ service. Either all the bytes in a write() 
>> should get sent or none of them. Sending a paritial datagram is _not_ 
>> a valid option.
>
> I would agree with the above if you said send() instead of write().

Good point -- I meant send().  I keep forgetting that the libc socket
write() operation is missing in Python and only the send() call has
been made visible. In C write() and send() are effectively the same
thing (the parameters are arranged a little differently, but they
behave identically otherwise).

> Python socket objects don't have write() methods, file objects do.  You 
> can wrap a file around a socket with socket.makefile(), but I'm not sure 
> I would expect the UDP record boundary semantics to be honored once you 
> did that.

No, I wouldn't exect that.

-- 
Grant Edwards   grant.b.edwardsYow! I wish I was on a
  at   Cincinnati street corner
  gmail.comholding a clean dog!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: New to Python, Help to get script working?

2013-12-15 Thread Chris Angelico
On Mon, Dec 16, 2013 at 8:31 AM, Mark  wrote:
> I originally get an indent error on line 19, i delete the indent and i get
>
> ***'return outside function (Twitch.py, line 19)

Good point, someone's made a mistake in that file. What you need to do
is match the "output = ..." line and the "return ..." line underneath
it. For consistency with the rest of the file, indent the "output"
line to match the other. That should make it work.

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


Re: GUI:-please answer want to learn GUI programming in python , how should i proceed.

2013-12-15 Thread Chris Angelico
On Mon, Dec 16, 2013 at 4:01 AM, Steven D'Aprano
 wrote:
> As I stated earlier, this is just the Interpreter design pattern, with
> the minor complication that the domain specific language happens to be an
> existing language, Tcl, with an interpreter that usually runs in a
> separate process, instead of some mini-language running inside Python.

Yeah, but there's a difference between passing your GUI incantations
on to a library function (written in C but now just part of a binary
library) and feeding them to a completely different language
interpreter. When I write something with PyGTK, I can't, even in
theory, give it arbitrary C code to execute. From what I understand
here, that *is* true of Tcl, which means that the Python download
contains a Python interpreter and a Tcl interpreter. I'm not saying
that's a bad thing to do, but it is calculated to provoke remark.

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


Re: New to Python, Help to get script working?

2013-12-15 Thread Mark
On Sunday, December 15, 2013 4:19:47 PM UTC-5, Mark wrote:
> Thanks for the replies, I was hoping that one of you guys could actually try 
> it for me, as it might be easier to correct? In the meantime i will install 
> 2.7 instead of 3.3 and give it a try.
> 
> 
> 
> Once again, i have very little experience in this, which is why i am looking 
> for help :) I am more worried about getting it to work then knowing whats 
> wrong, but it could also be helpful haha
> 
> 
> 
> Thanks
> 
> 
> 
> Mark

I originally get an indent error on line 19, i delete the indent and i get 

***'return outside function (Twitch.py, line 19)

Thats where i am at. This is on version 2.7

If anybody could correct this for me or provide some incite. i would be very 
grateful. If any of you would be available for some sort of chat to fix it, I 
would also love to do something like that. 

Thanks again

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


Re: New to Python, Help to get script working?

2013-12-15 Thread Mark
Thanks for the replies, I was hoping that one of you guys could actually try it 
for me, as it might be easier to correct? In the meantime i will install 2.7 
instead of 3.3 and give it a try.

Once again, i have very little experience in this, which is why i am looking 
for help :) I am more worried about getting it to work then knowing whats 
wrong, but it could also be helpful haha

Thanks

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


Re: [newbie] trying socket as a replacement for nc

2013-12-15 Thread Dan Stromberg
On Sun, Dec 15, 2013 at 7:35 AM, Jean Dubois  wrote:

>> You can "svn checkout ".  You might try Sliksvn if you're on
>> Windows, or if you're on Linux it's in synaptic or yum or whatever.
>> You can "wget ".
>> You can bring up the URL in a web browser and cut and paste.
> I'm using Linux, I did the following:
> svn checkout http://stromberg.dnsalias.org/svn/bufsock/
> which resulted in a directory 'bufsock' being added to my home-directory,
> Do I have to run further commands on the files in this directory?
> How do I make Python aware of the existence of this new module?

You can put the files (bufsock.py and python2x3.py) in your current
working directory - Python will import from your CWD.  I believe
python2x3.py should be checked out via an external reference since you
used svn.

You can put the files in your site-packages directory.

You can put the files in a directory like ~/lib, and then
sys.path.insert(0, os.path.expanduser('~/lib')) .

I probably should make it pip'able, but I don't think it's going to
happen today.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: a Python Static Analyzer

2013-12-15 Thread Mark Lawrence

On 15/12/2013 20:25, arie.lake...@gmail.com wrote:

On Sunday, 15 December 2013 02:36:56 UTC, Chris Rebert  wrote:

On Sat, Dec 14, 2013 at 5:31 PM, Dan Stromberg  wrote:


Where does PySonar2 sit in the spectrum from pylint



(thorough/pedantic) to pyflakes (relaxed/few-false-positives)?







I use pylint and pyflakes a lot, and I've heard that PyChecker sits in



between them on this axis.




My impression is that PyChecker has been abandoned.

The last commit in its SourceForge CVS repo is from 2008, and `pip

install PyChecker` fails.



Cheers,

Chris


Hi Chris,

I can't comment on the comparative sophistication of PySonar2 to pylint and 
pyflakes, my experience of those two projects is as code quality tools, whereas 
I've been using PySonar2 for things along the lines of indexing code at a more 
semantic level, something I'm satisfied with.

Here's a comment on a reddit post about PySonar a month ago

http://www.reddit.com/comments/1piusr

`
Yin Wang is awesome and his work on programming languages and type inference is 
super impressive. We've been using his PySonar (v1) to build a global index of 
Python code and it works far better than we or anyone would have expected, for 
a dynamic language.
Here are some examples of what PySonar can do:
Finding everywhere a function is used
Python stdlib, sorted by most-used functions
All usages of the Django URL render_to_response function
All usages of the Flask @app.route decorator
This is all done using PySonar v1-based static analysis on Python code. PySonar 
v2 is even better.
`

I've referred Yin to this google group post.



Looks like very good work, thanks for the data.

But please note that I'm reading this via email, not google groups.  If 
you'd care to look above, you'll observe the double line spacing that 
gets inserted into everything that we see from gg, unless you read and 
action this https://wiki.python.org/moin/GoogleGroupsPython  If you'd be 
kind enough to do this it would be greatly appreciated by many people 
here.  TIA.


--
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.


Mark Lawrence

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


Re: a Python Static Analyzer

2013-12-15 Thread arie . lakeman
On Sunday, 15 December 2013 02:36:56 UTC, Chris Rebert  wrote:
> On Sat, Dec 14, 2013 at 5:31 PM, Dan Stromberg  wrote:
> 
> > Where does PySonar2 sit in the spectrum from pylint
> 
> > (thorough/pedantic) to pyflakes (relaxed/few-false-positives)?
> 
> >
> 
> > I use pylint and pyflakes a lot, and I've heard that PyChecker sits in
> 
> > between them on this axis.
> 
> 
> 
> My impression is that PyChecker has been abandoned.
> 
> The last commit in its SourceForge CVS repo is from 2008, and `pip
> 
> install PyChecker` fails.
> 
> 
> 
> Cheers,
> 
> Chris

Hi Chris,

I can't comment on the comparative sophistication of PySonar2 to pylint and 
pyflakes, my experience of those two projects is as code quality tools, whereas 
I've been using PySonar2 for things along the lines of indexing code at a more 
semantic level, something I'm satisfied with.

Here's a comment on a reddit post about PySonar a month ago

http://www.reddit.com/comments/1piusr

`
Yin Wang is awesome and his work on programming languages and type inference is 
super impressive. We've been using his PySonar (v1) to build a global index of 
Python code and it works far better than we or anyone would have expected, for 
a dynamic language.
Here are some examples of what PySonar can do:
Finding everywhere a function is used
Python stdlib, sorted by most-used functions
All usages of the Django URL render_to_response function
All usages of the Flask @app.route decorator
This is all done using PySonar v1-based static analysis on Python code. PySonar 
v2 is even better.
`

I've referred Yin to this google group post.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: GUI:-please answer want to learn GUI programming in python , how should i proceed.

2013-12-15 Thread Mark Lawrence

On 15/12/2013 17:52, Chris “Kwpolska” Warrick wrote:

On Sun, Dec 15, 2013 at 4:33 PM, Wolfgang Keller  wrote:

And besides, again, a commercially licensed PyQt itself isn't *that*
expensive.



The cost of a commercial PyQt license for a single developer is £350
(GBP). You may pay in either US Dollars, Euros or GBP.


(£420 incl. VAT for UK and select EU entities)


Four weeks income, no thanks :(




one [license] per developer


For some people, it might be a lot.  Why waste money on something,
that has an almost-identical free-for-everyone version? (which also is
easier to install, BTW)


PyQt does not include Qt itself. You must also obtain an
appropriately licensed copy (either the commercial version from
Digia or the LGPL version from the Qt Project).


So, you have four options:

a) use PySide and Qt@Project, pay $0 and be sane (albeit saner than
person B);
b) use PyQt4 and Qt@Digia, pay £350/£420 + £??? and be sane;
c) use PySide and Qt@Digia, pay £??? and look like a hypocrite (albeit
less than person D);
d) use PyQt4 and Qt@Project, pay £350/£420 and look like a hypocrite.

DISCLAIMER: Some things are based on assumptions, many of which may be
 incorrect.

PS. For those living in the past without proper Unicode support: £ = GBP.



Thanks for making my day, I've roared with laughter at the PS.

--
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.


Mark Lawrence

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


Re: GUI:-please answer want to learn GUI programming in python , how should i proceed.

2013-12-15 Thread Chris “Kwpolska” Warrick
On Sun, Dec 15, 2013 at 4:33 PM, Wolfgang Keller  wrote:
> And besides, again, a commercially licensed PyQt itself isn't *that*
> expensive.

> The cost of a commercial PyQt license for a single developer is £350
> (GBP). You may pay in either US Dollars, Euros or GBP.

(£420 incl. VAT for UK and select EU entities)

> one [license] per developer

For some people, it might be a lot.  Why waste money on something,
that has an almost-identical free-for-everyone version? (which also is
easier to install, BTW)

> PyQt does not include Qt itself. You must also obtain an
> appropriately licensed copy (either the commercial version from
> Digia or the LGPL version from the Qt Project).

So, you have four options:

a) use PySide and Qt@Project, pay $0 and be sane (albeit saner than
   person B);
b) use PyQt4 and Qt@Digia, pay £350/£420 + £??? and be sane;
c) use PySide and Qt@Digia, pay £??? and look like a hypocrite (albeit
   less than person D);
d) use PyQt4 and Qt@Project, pay £350/£420 and look like a hypocrite.

DISCLAIMER: Some things are based on assumptions, many of which may be
incorrect.

PS. For those living in the past without proper Unicode support: £ = GBP.

-- 
Chris “Kwpolska” Warrick 
PGP: 5EAAEA16
stop html mail | always bottom-post | only UTF-8 makes sense
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [newbie] trying socket as a replacement for nc

2013-12-15 Thread Roy Smith
In article ,
 Chris Angelico  wrote:

> On Mon, Dec 16, 2013 at 2:51 AM, Roy Smith  wrote:
> > In article ,
> >  Grant Edwards  wrote:
> >
> >> UDP is a a _datagram_ service. Either all the bytes in a write()
> >> should get sent or none of them. Sending a paritial datagram is _not_
> >> a valid option.
> >
> > I would agree with the above if you said send() instead of write().
> > Python socket objects don't have write() methods, file objects do.  You
> > can wrap a file around a socket with socket.makefile(), but I'm not sure
> > I would expect the UDP record boundary semantics to be honored once you
> > did that.
> 
> The underlying C API allows you, on Unix-like systems at least, to use
> the standard write() function to send UDP packets (as long as you
> first connect() - otherwise you need sendto() to specify a
> destination). I don't usually use that method, but I would expect that
> one call to write() becomes one UDP packet.

At the Unix system call level, yes.  But, given that this is a Python 
newsgroup, I made the assumption we were talking about the Python API 
level.  Silly me :-)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python for IPSA (Power flow analysis)

2013-12-15 Thread muhamadwahidi
Pada Selasa, 28 Mei 2013 17:00:42 UTC+7, Debbie  menulis:
> Hi there,
> 
> I am new to Python, and wondering if you could help me with python based 
> coding for the IPSA (Power system analysis software). I have a electrical 
> distribution network with generators, buses and loads, on which I am 
> performing the load flow analysis every 1 hour for a period of 1 year. 
> 
> 
> 
> The code to perform instantaneous load/power flow analysis is given below. I 
> need to modify it such that I can perform this load flow analysis every 1 
> hour for a period of 1 year. Please help.
> 
> 
> 
> from ipsa import *
> 
> 
> 
> ipsasys = IscInterface()
> 
> net = ipsasys.ReadFile("refinery.iif")
> 
> bok = net.DoLoadFlow();
> 
> if bok:
> 
> busbars = net.GetBusbars()
> 
> print "Load Flow results:"
> 
> print ""
> 
> print "BusName Vmag(kV)"
> 
> print ""
> 
> for bus in busbars.itervalues():
> 
> name = bus.GetName()
> 
> vm = bus.GetVoltageMagnitudekV()
> 
> res = "%-8s  %10.5f" % (name, vm)
> 
> print res
> 
> else:
> 
> print "Load Flow failed!"
> 
> 
> 
> Regards,
> 
> Debbie

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


Re: GUI:-please answer want to learn GUI programming in python , how should i proceed.

2013-12-15 Thread Michael Torrie
On 12/15/2013 08:33 AM, Wolfgang Keller wrote:
>> I think PyQt is slowly being pushed aside in favor of PySide, which is
>> more license-friendly for use in closed or open projects.  I would
>> recommend using PySide unless PyQt is a requirement for your project.
> 
> Except the issue that Pyside always seems to lag a bit behind Qt
> releases, while PyQt usually supports more recent releases of Qt.

Which is a bit odd, seeing as Pyside is an official Qt project.  It was
started by Nokia when they owned Qt, and now is hosted at the official
Qt web site.

> Besides that, according to what I've been reading on the PyQt mailing
> list, support is impressive. The developer often fixes issues over
> night, if there actually are any. And besides, again, a commercially
> licensed PyQt itself isn't *that* expensive.

That's good to know.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: GUI:-please answer want to learn GUI programming in python , how should i proceed.

2013-12-15 Thread Steven D'Aprano
On Sun, 15 Dec 2013 14:53:45 +, Grant Edwards wrote:

> On 2013-12-14, Steven D'Aprano 
> wrote:
> 
>> But more seriously, 100% seriously in fact, I think that you'll find
>> that *every* GUI framework for Python ships with an entirely different
>> language under the hood, usually C.
> 
> Name one GUI framework that ships with a C implementation.

Er, all of them? I daresay that Tcl itself eventually calls graphics 
routines written in C. There's not that many languages that commonly get 
used for low-level graphics routines, but C is one of them.

If you mean, ships with a C *compiler*, or even a C interpreter, then no, 
probably not. But it wouldn't surprise me if some of those GUI frameworks 
are powerful enough to count as mini-languages in their own right.


>> Even if the top level of the framework is written in Python, the
>> underlying graphics routines used for drawing controls and windows will
>> surely not be.
> 
> You seem to be equating "was compiled from" with "includes an
> implemenation of".  Do you say that CPython "ships with C"?

Well, when you take my comments out of their context, that does seem to 
be a totally stupid thing to say. But in context, it's only *mostly* 
stupid, and mostly stupid means a little bit sensible *wink*

The context was a complaint, or at least expression of surprise, that 
Python use Tcl for a GUI, this being contrasted with (paraphrasing the 
legions of people who have expressed surprise about this in the past) 
"some hypothetical GUI written in Python". But in practice, it won't be 
written in Python, it will be likely written in C or some other low-level 
language with some interface to Python. The main difference between this 
hypothetical "Python GUI" and Tcl is that Tcl is a Turing-complete 
interpreter which lives in it's own process. 

[Aside: I wonder how many other GUI toolkits are Turing complete?]

As I stated earlier, this is just the Interpreter design pattern, with 
the minor complication that the domain specific language happens to be an 
existing language, Tcl, with an interpreter that usually runs in a 
separate process, instead of some mini-language running inside Python.

So I don't see anything surprising about Tkinter (or for that matter, 
Ruby and it's bindings to Tcl/Tk). Maybe it's because I'm used to Unix/
Linux systems, where it is common for tools that execute in one 
interpreter to call other tools which execute in a different interpreter. 
E.g. a shell script which calls a Ruby script which calls some command 
which happens to be written in Python. Python, after all, was originally 
invented to be a glue language, and I don't really see anything weird 
about Python delegating work to Tcl any more than I see anything strange 
about IronPython delegating work to the .Net runtime.



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


Re: collections Counter most_common method

2013-12-15 Thread Mark Lawrence

On 14/12/2013 19:42, Peter Otten wrote:

Mark Lawrence wrote:


This method returns a list, the example from The Fine Docs being:-

  >>> Counter('abracadabra').most_common(3)
[('a', 5), ('r', 2), ('b', 2)]

With the trend in Python being more and more towards methods returning
iterators, is there ever likely to be an imost_common method, or has
this been suggested and rejected, or what?  I'm really just curious, but
if enough people were to express an interest and it hasn't already been
done, I'd happily raise an enhancement request on the bug tracker.


As Counter is currently a dict you have to look at all items to find the
most common. With that underlying data structure I don't see how it could
make sense to yield the most common items incrementally. So

(1) When would you prefer it over the the eager variant?
(2) How would you implement it?

By the way, if you can come up with a plausible answer for the second
question you should aim higher, for lazy heapq.nlargest() and sorted()
functions...



Coming from my No. 1 MVP (Most Valuable Pythonista) I'll take that as an 
emphatic no :)


The good news from my POV is that while thinking about this, then 
looking at my code, I completely eliminated an unneeded data structure.


--
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.


Mark Lawrence

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


SQLObject 1.5.1

2013-12-15 Thread Oleg Broytman
Hello!

I'm pleased to announce version 1.5.1, the first bugfix release of branch
1.5 of SQLObject.


What's new in SQLObject
===

* SQLiteConnection.close() now closes and reopens a connection
  to in-memory database.

Contributor for this release is Maciej (Matchek) Blizinski.

For a more complete list, please see the news:
http://sqlobject.org/News.html


What is SQLObject
=

SQLObject is an object-relational mapper.  Your database tables are described
as classes, and rows are instances of those classes.  SQLObject is meant to be
easy to use and quick to get started with.

SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite,
Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB).


Where is SQLObject
==

Site:
http://sqlobject.org

Development:
http://sqlobject.org/devel/

Mailing list:
https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss

Archives:
http://news.gmane.org/gmane.comp.python.sqlobject

Download:
https://pypi.python.org/pypi/SQLObject/1.5.1

News and changes:
http://sqlobject.org/News.html

Oleg.
-- 
 Oleg Broytmanhttp://phdru.name/p...@phdru.name
   Programmers don't die, they just GOSUB without RETURN.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [newbie] trying socket as a replacement for nc

2013-12-15 Thread Chris Angelico
On Mon, Dec 16, 2013 at 2:51 AM, Roy Smith  wrote:
> In article ,
>  Grant Edwards  wrote:
>
>> UDP is a a _datagram_ service. Either all the bytes in a write()
>> should get sent or none of them. Sending a paritial datagram is _not_
>> a valid option.
>
> I would agree with the above if you said send() instead of write().
> Python socket objects don't have write() methods, file objects do.  You
> can wrap a file around a socket with socket.makefile(), but I'm not sure
> I would expect the UDP record boundary semantics to be honored once you
> did that.

The underlying C API allows you, on Unix-like systems at least, to use
the standard write() function to send UDP packets (as long as you
first connect() - otherwise you need sendto() to specify a
destination). I don't usually use that method, but I would expect that
one call to write() becomes one UDP packet.

How that works with socket.makefile() in Python I have no idea.

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


Re: [newbie] trying socket as a replacement for nc

2013-12-15 Thread Roy Smith
In article ,
 Grant Edwards  wrote:

> UDP is a a _datagram_ service. Either all the bytes in a write() 
> should get sent or none of them. Sending a paritial datagram is _not_ 
> a valid option.

I would agree with the above if you said send() instead of write().  
Python socket objects don't have write() methods, file objects do.  You 
can wrap a file around a socket with socket.makefile(), but I'm not sure 
I would expect the UDP record boundary semantics to be honored once you 
did that.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [newbie] trying socket as a replacement for nc

2013-12-15 Thread Chris Angelico
On Mon, Dec 16, 2013 at 2:35 AM, Jean Dubois  wrote:
> I'm using Linux, I did the following:
> svn checkout http://stromberg.dnsalias.org/svn/bufsock/
> which resulted in a directory 'bufsock' being added to my home-directory,
> Do I have to run further commands on the files in this directory?
> How do I make Python aware of the existence of this new module?

Have a look in that directory. It seems to simply have a bufsock.py
which is the module to import.

That said, though, you may have to deal with dependencies. The source
code of bufsock.py references a python2x3 module (which Google tells
me is by the same author), so you may need to grab that, too.

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


Re: [newbie] trying socket as a replacement for nc

2013-12-15 Thread Jean Dubois
Op zondag 15 december 2013 02:03:14 UTC+1 schreef Dan Stromberg:
> On Sat, Dec 14, 2013 at 5:33 AM, Jean Dubois  wrote:
> > Op vrijdag 13 december 2013 16:35:31 UTC+1 schreef Jean-Michel Pichavant:
> >> - Original Message -
> >> > I have an ethernet-rs232 adapter which allows me to connect to a
> >> > measurement instrument by means of netcat on a linux system.
> >> > e.g. entering nc 10.128.59.63 7000
> >> > allows me to enter e.g.
> >> > *IDN?
> >> > after which I get an identification string of the measurement
> >> > instrument back.
> >> > I thought I could accomplish the same using the python module
> >> > "socket"
> >> > and tried out the sample program below which doesn't work however:
> >> > #!/usr/bin/env python
> >> >
> >> > """
> >> > A simple echo client
> >> > """
> >> > import socket
> >> > host = '10.128.59.63'
> >> > port = 7000
> >> > size = 10
> >> > s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> >> > s.connect((host,port))
> >> > s.send('*IDN?')
> >> > data = s.recv(size)
> >> > s.close()
> >> > print 'Received:', data
> >> >
> >> > Can anyone here tell me how to do it properly?
> >> > thanks in advance
> >> > jean
> >> Such equipment often implements a telnet protocol. Have use try using the 
> >> telnetlib module ?
> >> http://docs.python.org/2/library/telnetlib.html
> >> t = Telnet(host, port)
> >> t.write('*IDN?')
> >> print t.read_until('Whateverprompt')
> >> # you can use read_very_eager also
> >> JM
> > Thanks for the suggestion, I'll first wait for a response from Dan 
> > Stromberg concerning how to install his module, if he doesn't answer or if 
> > I'm still unsuccessfull then I'll try out your suggestion
> >
> > kind regards,
> > jean
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> You can "svn checkout ".  You might try Sliksvn if you're on
> Windows, or if you're on Linux it's in synaptic or yum or whatever.
> You can "wget ".
> You can bring up the URL in a web browser and cut and paste.
I'm using Linux, I did the following:
svn checkout http://stromberg.dnsalias.org/svn/bufsock/
which resulted in a directory 'bufsock' being added to my home-directory, 
Do I have to run further commands on the files in this directory?
How do I make Python aware of the existence of this new module?

thanks in advance
jean 

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


Re: GUI:-please answer want to learn GUI programming in python , how should i proceed.

2013-12-15 Thread Wolfgang Keller
> I think PyQt is slowly being pushed aside in favor of PySide, which is
> more license-friendly for use in closed or open projects.  I would
> recommend using PySide unless PyQt is a requirement for your project.

Except the issue that Pyside always seems to lag a bit behind Qt
releases, while PyQt usually supports more recent releases of Qt.

Besides that, according to what I've been reading on the PyQt mailing
list, support is impressive. The developer often fixes issues over
night, if there actually are any. And besides, again, a commercially
licensed PyQt itself isn't *that* expensive.

Sincerely,

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


Re: New to Python, Help to get script working?

2013-12-15 Thread Denis McMahon
On Sat, 14 Dec 2013 20:51:59 -0800, Mark wrote:

> I have successfully installed python 3.3 for windows, pip and
> livestreamer that is needed for it to work. They are in my scripts
> folder. I either do not understand the script or it no longer works. It
> is more than likely my error. I get errors on line 19 and cant get it to
> work at all.

If you're getting the "not enough goats and chickens sacrificed error", 
sacrifice more goats and chickens.

(Hint - it would help if you told us what the error was, and displayed at 
least the line the error occurs on and the preceding 10 lines or so)

-- 
Denis McMahon, denismfmcma...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [newbie] trying socket as a replacement for nc

2013-12-15 Thread Grant Edwards
On 2013-12-15, Dan Stromberg  wrote:
> On Fri, Dec 13, 2013 at 8:06 AM, Grant Edwards  
> wrote:
>> On 2013-12-12, Dan Stromberg  wrote:

 Just to be pedantic: _TCP_ sockets reserve that right.  UDP sockets
 do not, and do in fact guarantee that each message is discrete.  [It
 appears that the OP is undoubtedly using TCP sockets.]
>>>
>>> I haven't done a lot of UDP, but are you pretty sure UDP can't at
>>> least fragment large packets?  What's a router or switch to do if the
>>> Path MTU isn't large enough for an original packet?
>>>
>>> http://www.gamedev.net/topic/343577-fragmented-udp-packets/
>>
>> You're conflating IP datagrams and Ethernet packets.  The IP stack can
>> fragment an IP datagram into multiple Ethernet packets which are then
>> reassembled by the receiving IP stack into a single datagram before
>> being passed up to the next layer (in this case, UDP).
>
> As long as you're saying this of UDP, I have no problem with it.

That is indeed what I'm saying.  I apoligize if that was not clear in
my original posting.

> I've seen TCP fragment and not be reassembled though, which suggests
> to me that the reassembly's happening in UDP rather than IP.

That's something different.  In TCP, there's no guarantee that
reads/writes correspond 1:1 to IP datagrams.  TCP is a _stream_
protocol and there is no semantic meaning attached to the boundaries
between successive read/write calls the way there is with UDP.

> If it's done by IP the same way for UDP and TCP,

The IP layer is supposed to reassemble receive datagrams for both --
but that's got nothing to do with atomicity of TCP writes/reads.  The
TCP stack can (and often does) turn one write() call into multiple IP
datagrams.  It can also turn multiple writes into a singel IP
datagram.  On the other end, it can split up a single datagram into
multiple read()s and/or combined multiple datagrams into a single
read().  TCP is a stream service, not a datagram service like UDP.

> I'd not trust it in UDP either.

The standards all require UDP datagrams to be preserved.  All of the
UDP applications I've ever written or seen depend utterly on that, and
it's always worked that way for me.  If you've seen it fail, then you
ought to file a bug report.

>> Did you read the thread you pointed to?  Your question was answerd by
>> posting #4 in the thread you cited:
>>
>>1) Yes, packets will be fragmented at the network layer (IP), but
>>   this is something you do not have to worry about since the
>>   network layer will reassemble the fragments before passing them
>>   back up to the transport layer (UDP). UDP garentees preserved
>>   message boundaries, so you never have to worry about only
>>   receiving a packet fragment :~).
>
> Actually, I believe the link I sent (which I skimmed) had people
> coming down on both sides of the matter.  Some said that UDP would be
> fine for small datagrams, while others said it would be fine,
> irrespective of size.

The maximum size of an IP datagram is 64KB, so it's not "fine
irrespecive of size".  If your UDP implementation is working correctly
it will be fine below that limit.

>> A few other references:
>>
>> http://tools.ietf.org/html/rfc791
>>
>>  1.1. Motivation
>>
>>   [...] The internet protocol provides for transmitting blocks of data
>>   called datagrams from sources to destinations, [...] The internet
>>   protocol also provides for fragmentation and reassembly of long
>>   datagrams, if necessary, for transmission through "small packet"
>>   networks.
>
> I've personally seen this fail to occur in TCP

You can't say that, because there's no correspondance between IP
datgrams and TCP read/write block sizes the way there is in UDP. 

With TCP there is nothing to fail (with respect to read/write block
sizes). TCP only guarantees that bytes will get there and get there in
the right order. It doesn't make any promises about block sizes.

> I've seen old time socket programmers explain that it cannot be relied
> upon in TCP; send() and recv() and (read() and write()) are system
> calls that return a length so that you can loop on them until all
> relevant data has been transferred.  They don't return that length
> just so you can ignore it.

That's true, but that's because of the design of the TCP _stream_
protocol, not because the IP datagram layer doesn't work right.
>
>>From the Socket HOWTO
>
> (http://docs.python.org/2/howto/sockets.html#socket-howto) : Now we
> come to the major stumbling block of sockets - send and recv operate
> on the network buffers. They do not necessarily handle all the bytes
> you hand them (or expect from them), because their major focus is
> handling the network buffers. In general, they return when the
> associated network buffers have been filled (send) or emptied (recv).
> They then tell you how many bytes they handled. It is your
> responsibility to call them again until your message has been
> completely dealt with.

If that's true for UDP, t

Re: GUI:-please answer want to learn GUI programming in python , how should i proceed.

2013-12-15 Thread Grant Edwards
On 2013-12-14, Steven D'Aprano  wrote:

> But more seriously, 100% seriously in fact, I think that you'll find that 
> *every* GUI framework for Python ships with an entirely different 
> language under the hood, usually C.

Name one GUI framework that ships with a C implementation.

> Even if the top level of the framework is written in Python, the
> underlying graphics routines used for drawing controls and windows
> will surely not be.

You seem to be equating "was compiled from" with "includes an
implemenation of".  Do you say that CPython "ships with C"?

-- 
Grant
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: CP65001 fails (was re: ...)

2013-12-15 Thread Mark Lawrence

On 15/12/2013 04:48, Chris Angelico wrote:

On Sun, Dec 15, 2013 at 3:42 PM, rusi  wrote:

To me all this GG complaining sounds like some elderly mom-pop-uncle
who weeps/coaxes/moans/pleads/grumbles/ about a fused light bulb,
rather than climbing on a stool and changing the bloody thing.


No, it's like moaning about Foo Brand light bulbs that die after two
weeks, when there are perfectly good light bulbs that last for years
if you'll just use a different brand. And there are people who say
"But Foo Brand light bulbs are easy, you just go up on a ladder every
time you want to turn it on and make sure there's a good bulb in it!".

ChrisA



On this count I observe that on 15/12/2013 GMT at 08:26 the cows still 
haven't come home :)


--
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.


Mark Lawrence

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


Re: Eliminate "extra" variable

2013-12-15 Thread Tim Chase
On 2013-12-15 06:17, Tim Chase wrote:
>> conn = sqlite3.connect('x.sqlite',
>>>... detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)
> 
> Your example code omitted this one crucial line.  Do you specify the
> detect_types parameter to connect()?

It's really the PARSE_DECLTYPES that is important.

http://docs.python.org/2/library/sqlite3.html#sqlite3.PARSE_DECLTYPES

-tkc


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


Re: Eliminate "extra" variable

2013-12-15 Thread Tim Chase
On 2013-12-14 23:49, Igor Korot wrote:
> Tim,
> 
> On Sun, Dec 8, 2013 at 2:18 PM, Tim Chase wrote:
> conn = sqlite3.connect('x.sqlite',
>>... detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)

Your example code omitted this one crucial line.  Do you specify the
detect_types parameter to connect()?

-tkc



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


Re: CP65001 fails (was re: ...)

2013-12-15 Thread wxjmfauth
Le dimanche 15 décembre 2013 06:07:09 UTC+1, Terry Reedy a écrit :
> On 12/14/2013 9:39 PM, Steven D'Aprano wrote:
> 
> > On Sat, 14 Dec 2013 13:43:41 -0500, Terry Reedy wrote:
> 
> >
> 
> >> This was reported by Victor Stinner as part of
> 
> >> http://bugs.python.org/issue19914
> 
> >> to explain how cp65001 causes behavior like this with Python's
> 
> >> interactive help() function (which more for paging on Windows).
> 
> >>
> 
> >>   >>> help(str)
> 
> >> Not enough memory.
> 
> >
> 
> >
> 
> > Terry, I see you have closed the bug report. I think you were a little
> 
> > hasty.
> 
> 
> 
> I might have been premature, but I was not hasty. I read the SO reports 
> 
> and though about it for an hour or so while looking at other issues. I 
> 
> did not see any use to leaving it open as I did not see any realistic 
> 
> propect of a useful and acceptible patch to Python. The OP himself said 
> 
> that i/o did not work with 65001 and that not using it fixed his issue.
> 
> 
> 
> > The ultimate cause of the bug may be the failure of Window's
> 
> > "more" command when the code-page is set to CP-65001, but that doesn't
> 
> > necessarily imply that Python shouldn't, or can't, do something about it.
> 
> 
> 
> I believe running Python on Windows with cp=65001 falls in the category 
> 
> of "Don't do that". This is based on my experiences and the reported 
> 
> experience of other developers who have tried and failed to make it 
> 
> work, reinforced by the SO thread and a couple of other web pages.
> 
> 
> 
> > The interactive help system already supports different pagers, depending
> 
> > on the environment. I think that it could fall back on a more primitive
> 
> > pager if the preferred one fails.
> 
> 
> 
> Do you know if 'more' actually signals failure?
> 
> Do you know if there are any other situations in which a pager fails?
> 
> 
> 
> > The relevant code is the pager() and
> 
> > getpager() functions in the pydoc module. The patch won't be trivial, but
> 
> > I think it can be done, and I think it should be done. Although possibly
> 
> > for Python 3.5 rather than a bug-fix version. Your thoughts?
> 
> 
> 
> My thought is that if the only situation in which a pager fails is one 
> 
> that one should not use, because other things will also fail, then a 
> 
> patch would not be worth the bother.
> 
> 


If I'm understanding a little bit about coding of
characters, fonts, chars "inputing", I should say
I never really understood how all this stuff is
arranged. (I never found a real explanation too).


There is something, which may be very deeply bound to
the system (kernel ?). As an example, entering a
char with Alt+0XXX always works accordingly to my (the?)
localized windows version. Entering a char with
Alt+XXX (not the missing 0) uses the OEM (bios?)
encoding.

jmf

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