ANN: RPQueue 0.21

2013-09-20 Thread Josiah Carlson
Hello everyone,

For those of you who didn't know, if you are interested in a Redis-backed
time and/or fifo-queue with priorities, retries, etc., to be used with
Python, one exists and is mature: it's called RPQueue, and it seeks to
simplify your life of task execution. The recent changelog entries are
below my signature.

The package has been around for two years next month, and does exactly what
you expect it to do - no more, no less.

You can find the package at:
https://github.com/josiahcarlson/rpqueue/
https://pypi.python.org/pypi/rpqueue

Please CC me on any replies if you have any questions or comments.

Thank you,
 - Josiah

#--- 0.21

[changed] where available, rpqueue will now use Lua to move delayed tasks
from
the time-based priority queue to fifo queues. This should reduce
overhead
in all cases, and should drastically improve performance for those that
use large numbers of delayed tasks.
[changed] the version number is now PEP 386/440 compliant.
[added] this changelog that will document updates/changes/improvements in an
easily referenced location.
[fixed] thanks to https://github.com/dmaust , rpqueue added a missing
'redis'
requirement.
-- 
https://mail.python.org/mailman/listinfo/python-announce-list

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


Re: Tryign to send mail via a python script by using the local MTA

2013-09-20 Thread Antoon Pardon
Op 20-09-13 05:56, Jake Angulo schreef:
 Up Robert Kern's reply!
 
 I was waiting for smtplib http://docs.python.org/2/library/smtplib to
 be mentioned... finally!  Instead people simply answer philosophically.
  I dont want to judge whether OP is a troll or not - but i found a lot
 of arrogant replies here.

That is nice. You don't like to judge the OP but you seem to have no
trouble judging others

 I have also worked on an antispam project
 before, and see through the intents of the OP, but I do not pretend to
 be a moralist.

That doesn't sound right after you judged other replies to be arrogant.

 I was hoping we would strictly discuss code or software
 architecture here, not morality. Simple question, simple answer pls, in
 the interest of the Python list.

Well I was hoping, we wouldn't be plagued by trolls or help-vampires
or at least that other wouldn't (spoon) feed them. I guess we can
always hope.

 To the OP:  
 
 You might want to google smtplib, and use that instead of os calling a
 system command. Smtplib takes care of all the operating system's quirks
 for you, and still uses the os native sendmail program.

But that won't help in eliminating all the headers Nikos would like
to avoid. Like the receive line that will identify his host.

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


Can i run my python program under andriod?

2013-09-20 Thread Mohsen Pahlevanzadeh
Dear all,

I need to binary with distutils, and run it under android OS,
Do you have any experience?

yours,
Mohsen

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


Re: Why does it have red squiggly lines under it if it works perfectly fine and no errors happen when I run it?

2013-09-20 Thread William Bryant
On Friday, September 20, 2013 11:09:03 AM UTC+12, Ian wrote:
 On Thu, Sep 19, 2013 at 1:22 PM, William Bryant gogobe...@gmail.com wrote:
 
  It was the other functions above it. Thanks. but I tried to do the while
 
  loop - I don't think I did it right, I am novice in python and I am 13 years
 
  old.
 
 
 
 It should be structured like this:
 
 
 
 while True:
 
 answer = input(Enter yes/no:)
 
 if answer in ('y', 'yes', 'new list'):
 
 do_yes_stuff()
 
 break
 
 elif answer in ('n', 'no', 'close'):
 
 do_no_stuff()
 
 break
 
 else:
 
 print(Please enter y or n.)
 
 
 
 If they answer 'yes' or 'no', then the break statement breaks out of
 
 the while loop.  Otherwise the while loop continues from the top and
 
 asks them again.

Thanks a lot! I have one more question, is there any way I can make my program 
work on android tablets and ipads? Because I'd like to use it in school because 
we are learning statistics and we are allowed our devices in school.


'''**'''
#* Name:Mode-Median-Mean Calculator   *#
#**#
#* Purpose: To calculate the mode, median and mean of a list of numbers   *#
#*  and the mode of a list of strings because that is what we are *#
#*  learning in math atm in school :P *#
#**#
#* Author:  William Bryant*#
#**#
#* Created: 11/09/2013*#
#**#
#* Copyright:   (c) William 2013  *#
#**#
#* Licence: IDK :3*#
'''**'''



#-#   ~~Import things I am using~~   #-#

# |
#|
#   \/

import time
import itertools



#-#~~Variables that I am using, including the list.~~#-#

# |
#|
#   \/

List = []
NumberOfXItems = []

#-#   ~~Functions that I am using.~~ #-#

# |
#|
#   \/

def HMNs():
global TheStr, user_inputHMNs, List_input, List
user_inputHMNs = input(You picked string. This program cannot calculate 
the mean or median, but it can calculate the mode. :D  How many strings are you 
using in your list? (Can not be a decimal number)  \nEnter:  )
if user_inputHMNs == restart:
NOS()
time.sleep(1.5)
TheStr = int(user_inputHMNs)
for i in range(TheStr):
List_input = input(Enter your strings. (One in each input field):  \n)
if List_input == restart:
NOS()
List.append(List_input)

print(\nThis
 is the amount of strings you are using in your list:, user_inputHMNs)
print(and this is how much space you have left in your list for 
strings:, int(user_inputHMNs) - len(List), 
\n\n)
print(Your list - , List)
print((0 is the first number in your list)\n)
for i in range(len(List)):
print(number  + str(i) + :  + str(List[i]))
print(\n*Mode*:, mode())
print(*Median*:,  There is no median for a list of strings - Only 
mode)
print(*Mean*:,There is no mean for a list of strings - Only 
mode)
if int(user_inputHMNs) - len(List) == 0:
init()


def HMNn():
global TheNum, user_inputHMNn, List_input, List
user_inputHMNn = input(You picked number. :D How many numbers are you 
using in your list? (Can not be a decimal number) \nEnter:  )
if user_inputHMNn == restart:
NOS()
time.sleep(1.5)
TheNum = int(user_inputHMNn)
for i in range(TheNum):
List_input = input(Enter your numbers. (One in each input field):  \n)
List_input = int(List_input)
if List_input == restart:
NOS()
List.append(List_input)

print(\nThis
 is the amount of numbers you are using in your list:, user_inputHMNn)
print(and this is how much space you have left in your list for 
numbers:, int(user_inputHMNn) - len(List), 
\n\n)

ANN: RPQueue 0.21

2013-09-20 Thread Josiah Carlson
Hello everyone,

For those of you who didn't know, if you are interested in a Redis-backed
time and/or fifo-queue with priorities, retries, etc., to be used with
Python, one exists and is mature: it's called RPQueue, and it seeks to
simplify your life of task execution. The recent changelog entries are
below my signature.

The package has been around for two years next month, and does exactly what
you expect it to do - no more, no less.

You can find the package at:
https://github.com/josiahcarlson/rpqueue/
https://pypi.python.org/pypi/rpqueue

Please CC me on any replies if you have any questions or comments.

Thank you,
 - Josiah

#--- 0.21

[changed] where available, rpqueue will now use Lua to move delayed tasks
from
the time-based priority queue to fifo queues. This should reduce
overhead
in all cases, and should drastically improve performance for those that
use large numbers of delayed tasks.
[changed] the version number is now PEP 386/440 compliant.
[added] this changelog that will document updates/changes/improvements in an
easily referenced location.
[fixed] thanks to https://github.com/dmaust , rpqueue added a missing
'redis'
requirement.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Tryign to send mail via a python script by using the local MTA

2013-09-20 Thread Robert Kern

On 2013-09-20 04:56, Jake Angulo wrote:

Up Robert Kern's reply!

I was waiting for smtplib http://docs.python.org/2/library/smtplib to be
mentioned... finally!  Instead people simply answer philosophically.  I dont
want to judge whether OP is a troll or not - but i found a lot of arrogant
replies here.  I have also worked on an antispam project before, and see through
the intents of the OP, but I do not pretend to be a moralist. I was hoping we
would strictly discuss code or software architecture here, not morality. Simple
question, simple answer pls, in the interest of the Python list.


Please don't valorize my message. I did neither Nikos nor the group any favors. 
I can only plead dizziness from the whooshing of Tim's sarcasm flying over 
Nikos' head.


--
Robert Kern

I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth.
  -- Umberto Eco

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


Re: Missing py2exe, needed 4 a gcode generator to engrave text in fancy ttf fonts in steel

2013-09-20 Thread Chris Angelico
On Fri, Sep 20, 2013 at 3:14 PM, Gene Heskett ghesk...@wdtv.com wrote:
 Can someone take a look at

 http://www.scorchworks.com/Fengrave/fengrave_setup.html#linux_fengrave

 Then this is what I get:
 gene@coyote:~/src/F-Engrave-1.22_src$ python py2exe_setup.py
 Traceback (most recent call last):
   File py2exe_setup.py, line 4, in module
 import py2exe
 ImportError: No module named py2exe

 And tell me how to fix this so it runs on an older linux box?

The page you link to doesn't mention py2exe anywhere. Where did you
get that you need to run that command?

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


What minimum should a person know before saying I know Python

2013-09-20 Thread Aseem Bansal
I started Python 4 months ago. Largely self-study with use of Python 
documentation, stackoverflow and google. I was thinking what is the minimum 
that I must know before I can say that I know Python?

I come from a C background which is comparatively smaller. But as Python is 
comparatively much larger what minimum should I know?

Just a general question not for a specific purpose. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Tryign to send mail via a python script by using the local MTA

2013-09-20 Thread feedthetroll
Hi Jake!

Am Freitag, 20. September 2013 05:56:57 UTC+2 schrieb Jake Angulo:
 ...
 I was waiting for smtplib to be mentioned... finally!  Instead people simply
 answer philosophically.  I dont want to judge whether OP is a troll or not -
As you do not seem to know the histrory of this topic I will try to summarize 
(you can find the plethora of posts in the archive):
* Nikos tried to send mails using smtplib via gmail
* gmail did not allow him to use arbitrary FROM adresses (whatever FROM-header 
he used, gmail changed it to the e-mail of his account). evil, evil gmail ;-)
* He got many, many hints not to send via gmail but use his own MTA
* Nikos configured sendmail to relay mail VIA GMAIL (unfortunately that did not 
change anything)
* while using arbitrary things to find the reason (when you browse the archive 
you will learn, that nikos does not read postings or docs but uses some sort of 
artistic or random or just chaotic trial and error to solve his problems)
* ... he found some other headers he wants to falsify
* the only reference to python is, that he wants to use his python-cgi-scripts 
to change the mailheaders AFTER the mail left his relaying MTA and even after 
the mail arrives in the inbox of the recipient (received-by-headers, 
IP-Adresses, ...). The hints to read some docs about TCP/IP, SMTP, ... he 
ignores as he has to do see 
http://www.politicsforum.org/images/flame_warriors/flame_62.php (the original 
by mreed is not reachable today)

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


Re: What minimum should a person know before saying I know Python

2013-09-20 Thread rusi
On Friday, September 20, 2013 3:28:00 PM UTC+5:30, Aseem Bansal wrote:
 I started Python 4 months ago. Largely self-study with use of Python 
 documentation, stackoverflow and google. I was thinking what is the minimum 
 that I must know before I can say that I know Python?
 
 
 
 I come from a C background which is comparatively smaller. But as Python is 
 comparatively much larger what minimum should I know?
 
 
 
 Just a general question not for a specific purpose.

Stroustrup says he is still learning C++ and I know kids who have no qualms 
saying they know programming language L (for various values of L) after hardly 
an hour or two of mostly advertising and pep-talk exposure.
So without knowing what you mean my 'knowing' I am not going to try answering 
q-1

I am just curious about q-2 -- C is small compared to python -- whats your 
measure for that?

BTW 20 years ago I wrote about why C is very hard to learn and teach
In these intervening years some things have changed, some have not

See
http://blog.languager.org/2013/02/c-in-education-and-software-engineering.html#relevate
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What minimum should a person know before saying I know Python

2013-09-20 Thread Tim Chase
On 2013-09-20 02:58, Aseem Bansal wrote:
 I started Python 4 months ago. Largely self-study with use of
 Python documentation, stackoverflow and google. I was thinking what
 is the minimum that I must know before I can say that I know Python?

It's a fuzzy line.  A good while back, there was a thread regarding
Python interview questions:

http://www.mail-archive.com/python-list@python.org/msg168971.html

to which I replied with a pretty large list.  The idea was not to
ensure that people knew everything on it, but as a way to take stock
of somebody means by I know Python, which can mean anything from I
wrote _Hello World_ in Python once to I'm Guido/Raymond/Effbot.

Along with the Basics section of that email, I'd expect a reasonable
understanding of commonly-used libraries offered out of the box (at
least a breadth of what is there, even if you haven't used them
much).

Most of the history items in that list are somewhat moot unless you
have to support older Python (I still have some 2.4 installs that
don't let me use the with statement or sqlite by default).

-tkc




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


Making it a MultiThread!

2013-09-20 Thread stas poritskiy
Hello All!

I have a general question, 
i was posting here earlier while trying to troubleshoot a few things while 
developing an application, i was able to hit all of my goals, and make things 
work! Thank you all who contributed to my research, and again, sorry for poor 
formatting of the threads, i am slowly learning;)

I am working on integration of multiple GUI (Tkinter) elements, such a progress 
bar, label update, etc, and throughout my research i discovered that i need to 
have Threading modules used to distribute the calls for GUI update and 
processing of my main App.

My Application is broken into multiple Classes(modules), and i wanted to hear 
your thought on the best practices to implement the Threading model.

I was thinking to create a new py-module, and reference all other modules/class 
to it, and create thread.start() objects, that would execute the GUI part, 
other will handle GUI Updates, and other - will be doing the processing.

Please share some of your thought on this approach, or maybe you may suggest a 
more effective way.
thanks !
-- 
https://mail.python.org/mailman/listinfo/python-list


I want to print entry and exit message for functions , i have bunch of such function . How can i do it in decorator.

2013-09-20 Thread bab mis
def fun:
print entry
.
.
print exit
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why does it have red squiggly lines under it if it works perfectly fine and no errors happen when I run it?

2013-09-20 Thread William Ray Wing
On Sep 20, 2013, at 3:01 AM, William Bryant gogobe...@gmail.com wrote:

[byte]

 
 Thanks a lot! I have one more question, is there any way I can make my 
 program work on android tablets and ipads? Because I'd like to use it in 
 school because we are learning statistics and we are allowed our devices in 
 school.
 
 

[byte]

 
 Thanks again - Will 
 

Python doesn't come pre-installed on tablets the way it does on most computers. 
 However, there are low-cost commercial python apps for tablets.  The one I'm 
most familiar with is Pythonista, available for the iPad in the Apple App 
store.  Last time I looked it was $6.95.

Bill

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


Re: Missing py2exe, needed 4 a gcode generator to engrave text in fancy ttf fonts in steel

2013-09-20 Thread Gene Heskett
On Friday 20 September 2013 08:48:44 Chris Angelico did opine:

 On Fri, Sep 20, 2013 at 3:14 PM, Gene Heskett ghesk...@wdtv.com wrote:
  Can someone take a look at
  
  http://www.scorchworks.com/Fengrave/fengrave_setup.html#linux_fengrav
  e
  
  Then this is what I get:
  gene@coyote:~/src/F-Engrave-1.22_src$ python py2exe_setup.py
  
  Traceback (most recent call last):
File py2exe_setup.py, line 4, in module

  import py2exe
  
  ImportError: No module named py2exe
  
  And tell me how to fix this so it runs on an older linux box?
 
 The page you link to doesn't mention py2exe anywhere. Where did you
 get that you need to run that command?
 
 ChrisA

From the example command to run the setup, a short script:
gene@coyote:~/src/F-Engrave-1.22_src$ cat py2exe_setup.py
#run this from the command line: python py2exe_setup.py py2exe

from distutils.core import setup
import py2exe

setup(
options = {py2exe: {compressed: 1, optimize: 0, } },
zipfile = None,
console=[{script:f-engrave-122.py,icon_resources:
[(0,fengrave.ico),(0,fengrave.ico)]}]

As shown on the setup page accompanying this

http://www.scorchworks.com/Fengrave/fengrave.html#download, lower left of 
the list at the top of the page.  Supposedly by using the src, I can build 
it with TTF support, which is missing from the file offered in the right 
most python only column.  All the other checks and tests on the setup page 
work, and all the other dependencies appear to have been met.

The setup file itself I find, shouldn't have been included in the zip 
without a README.linux that says to skip it.

The shipped fengrave-122.py actually runs but is not finding any fonts.  
There s/b quite a few installed since I have used TrueTypeTracer 
extensively before.  But I may have my machines mixed, and the computer 
running the milling machine is probably where I did all that.

I haven't had my morning coffee yet, so I am ill equipt to do more ATM.

Thank you.





Cheers, Gene
-- 
There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order.
-Ed Howdershelt (Author)
My web page: http://gene.homelinux.net:6309/gene should be up!

Seize the day, put no trust in the morrow!
-- Quintus Horatius Flaccus (Horace)
A pen in the hand of this president is far more
dangerous than 200 million guns in the hands of
 law-abiding citizens.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: I want to print entry and exit message for functions , i have bunch of such function . How can i do it in decorator.

2013-09-20 Thread Peter Otten
bab mis wrote:

 def fun:
 print entry
 .
 .
 print exit


 def log(f):
... def g(*args, **kw):
... print enter, f.__name__
... try:
... return f(*args, **kw)
... finally:
... print exit, f.__name__
... return g
... 
 @log
... def divide(a, b):
... return a / b
... 
 divide(4, 2)
enter divide
exit divide
2
 divide(4, 0)
enter divide
exit divide
Traceback (most recent call last):
  File stdin, line 1, in module
  File stdin, line 5, in g
  File stdin, line 3, in divide
ZeroDivisionError: integer division or modulo by zero


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


Re: What minimum should a person know before saying I know Python

2013-09-20 Thread Robert Kern

On 2013-09-20 12:43, rusi wrote:

On Friday, September 20, 2013 3:28:00 PM UTC+5:30, Aseem Bansal wrote:

I started Python 4 months ago. Largely self-study with use of Python 
documentation, stackoverflow and google. I was thinking what is the minimum 
that I must know before I can say that I know Python?

I come from a C background which is comparatively smaller. But as Python is 
comparatively much larger what minimum should I know?

Just a general question not for a specific purpose.


Stroustrup says he is still learning C++ and I know kids who have no qualms 
saying they know programming language L (for various values of L) after hardly 
an hour or two of mostly advertising and pep-talk exposure.
So without knowing what you mean my 'knowing' I am not going to try answering 
q-1


I think that's his actual question: What do *you* mean by 'I know Python'? At 
what point in your Python career did you feel comfortable claiming that?


--
Robert Kern

I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth.
  -- Umberto Eco

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


Re: Why does it have red squiggly lines under it if it works perfectly fine and no errors happen when I run it?

2013-09-20 Thread Duncan Booth
William Bryant gogobe...@gmail.com wrote:

 Thanks a lot! I have one more question, is there any way I can make my
 program work on android tablets and ipads? Because I'd like to use it
 in school because we are learning statistics and we are allowed our
 devices in school. 
 

You can install SL4A on Android and that should let you run your script on 
an Android tablet. You may want to modify the script to work with the 
android UI, or it might be enough just to run it in a terminal window.

I don't believe there is an ipad equivalent, but so long as you have a 
network connection, another option to consider (that would work on both 
android and ipad) would be to run the script on a server somewhere and 
connect to it through a web browser. Have a look at https://c9.io as that 
gives you a full development environment that can be accessed through a web 
browser: I don't know how well it works on a tablet but it would be worth 
trying.


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


Re: What minimum should a person know before saying I know Python

2013-09-20 Thread Chris Angelico
On Fri, Sep 20, 2013 at 7:58 PM, Aseem Bansal asmbans...@gmail.com wrote:
 I started Python 4 months ago. Largely self-study with use of Python 
 documentation, stackoverflow and google. I was thinking what is the minimum 
 that I must know before I can say that I know Python?

 I come from a C background which is comparatively smaller. But as Python is 
 comparatively much larger what minimum should I know?

 Just a general question not for a specific purpose.

Interesting.

Everything's relative. I would say that I know Python at the point
where I am comfortable using it to solve problems, as opposed to using
it to learn Python. That is to say, when you choose Python (above
bash, or above some other language, or whatever) because it will take
you less time to achieve a goal in Python than in any other language,
when it's the goal that's important.

I'd also add, though it's somewhat tangential to the first, that
knowing Python also requires knowing when/where Python is a good
choice of language. I like to be able to make one-sentence summaries
of the form X is a good choice when you want to...:

* Python: put something together NOW, with no boilerplate
* Pike: run a server that reloads code without dropping connections
* C: implement a high level language (or a module for one)
* PHP: gouge your eyes out with a rusty fork, but aren't allowed to on work time
* Haskell: code functionally rather than imperatively (I'm not
familiar with a broad range of functional languages; someone who is
would be distinguishing them from each other)
* bash: execute a series of commands, with minimal processing in between
* Lua: embed a tiny and secure scripting language in an application
* JavaScript/ECMAScript: ditto, but less tiny
* Brainf*: gouge your eyes out with a rusty fork, but aren't allowed to use PHP

Etcetera. Familiarity with a language requires knowing both how to use
it and when to use it.

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


lambda - strange behavior

2013-09-20 Thread Kasper Guldmann
I was playing around with lambda functions, but I cannot seem to fully grasp
them. I was running the script below in Python 2.7.5, and it doesn't do what
I want it to. Are lambda functions really supposed to work that way. How do
I make it work as I intend?

f = []
for n in range(5):
f.append( lambda x: x*n )

assert( f[4](2) == 8 )
assert( f[3](3) == 9 )
assert( f[2](2) == 4 )
assert( f[1](8) == 8 )
assert( f[0](2) == 0 )

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


Antispam measures circumventing

2013-09-20 Thread Jugurtha Hadjar


Hello,

# I posted this on the tutor list, but my message wasn't displayed


I shared some assembly code (microcontrollers) and I had a comment wit 
my e-mail address for contact purposes.


Supposing my name is John Doe and the e-mail is john@hotmail.com, my 
e-mail was written like this:


removemejohn.dospames...@removemehotmail.com'

With a note saying to remove the capital letters.

Now, I wrote this :

for character in my_string:
... if (character == character.upper()) and (character !='@') and 
(character != '.'):

... my_string = my_string.replace(character,'')


And the end result was john@hotmail.com.

Is there a better way to do that ? Without using regular expressions 
(Looked *really* ugly and it doesn't really make sense, unlike the few 
lines I've written, which are obvious even to a beginner like me).


I obviously don't like SPAM, but I just thought If I were a spammer, 
how would I go about it.


Eventually, some algorithm of detecting the 
johndotdoeathotmaildotcom must exist.



Also, what would in your opinion make it *harder* for a non-human to 
retrieve the original e-mail address? Maybe a function with no inverse 
function ? Generating an image that can't be converted back to text, etc..


If this is off-topic, you can just answer the what is a better way to 
do that part.


Thanks,



--
~Jugurtha Hadjar,

--
~Jugurtha Hadjar,
--
https://mail.python.org/mailman/listinfo/python-list


Re: Antispam measures circumventing

2013-09-20 Thread Vlastimil Brom
2013/9/20 Jugurtha Hadjar jugurtha.had...@gmail.com:
 Hello,
 # I posted this on the tutor list, but my message wasn't displayed
 I shared some assembly code (microcontrollers) and I had a comment wit my
 e-mail address for contact purposes.
 Supposing my name is John Doe and the e-mail is john@hotmail.com, my
 e-mail was written like this:
 removemejohn.dospames...@removemehotmail.com'
 With a note saying to remove the capital letters.
 Now, I wrote this :
 for character in my_string:
 ... if (character == character.upper()) and (character !='@') and
 (character != '.'):
 ... my_string = my_string.replace(character,'')
 And the end result was john@hotmail.com.
 Is there a better way to do that ? Without using regular expressions (Looked
 *really* ugly and it doesn't really make sense, unlike the few lines I've
 written, which are obvious even to a beginner like me).
 I obviously don't like SPAM, but I just thought If I were a spammer, how
 would I go about it.
 Eventually, some algorithm of detecting the johndotdoeathotmaildotcom
 must exist.
 retrieve the original e-mail address? Maybe a function with no inverse
 function ? Generating an image that can't be converted back to text, etc..
 If this is off-topic, you can just answer the what is a better way to do
 that part.

 Thanks,
 --
 ~Jugurtha Hadjar,
 --
 https://mail.python.org/mailman/listinfo/python-list


Hi,
is the regex really that bad for such simple replacement?

 re.sub(r[A-Z], , removemejohn.dospames...@removemehotmail.com)
'john@hotmail.com'

Alternatively, you can use a check with the string method  isupper():
 .join(char for char in removemejohn.dospames...@removemehotmail.com if 
 not char.isupper())
'john@hotmail.com'

or using a special form of str.translate()
 removemejohn.dospames...@removemehotmail.com.translate(None, 
 ABCDEFGHIJKLMNOPQRSTUVWXYZ)
'john@hotmail.com'

which is the same like:
 import string
 removemejohn.dospames...@removemehotmail.com.translate(None, 
 string.ascii_uppercase)
'john@hotmail.com'

Another possibility would be to utilise ord(...)
 .join(char for char in removemejohn.dospames...@removemehotmail.com if 
 ord(char) not in range(65, 91))
'john@hotmail.com'


Well, maybe there are other possibilities, these above are listed
roughly in the order of my personal preference. Of course, others may
differ...

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


Re: lambda - strange behavior

2013-09-20 Thread Chris Angelico
On Sat, Sep 21, 2013 at 1:21 AM, Kasper Guldmann gm...@kalleguld.dk wrote:
 f = []
 for n in range(5):
 f.append( lambda x: x*n )

You're leaving n as a free variable here. The lambda function will
happily look to an enclosing scope, so this doesn't work. But there is
a neat trick you can do:

f = []
for n in range(5):
f.append( lambda x,n=n: x*n )

You declare n as a second parameter, with a default value of the
current n. The two n's are technically completely separate, and one of
them is bound within the lambda.

BTW, any time you have a loop appending to a list, see if you can make
it a comprehension instead:

f = [lambda x,n=n: x*n for n in range(5)]

Often reads better, may execute better too.

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


Re: Antispam measures circumventing

2013-09-20 Thread Chris Angelico
On Sat, Sep 21, 2013 at 1:04 AM, Jugurtha Hadjar
jugurtha.had...@gmail.com wrote:
 Supposing my name is John Doe and the e-mail is john@hotmail.com, my
 e-mail was written like this:

 removemejohn.dospames...@removemehotmail.com'

 With a note saying to remove the capital letters.

 Now, I wrote this :

 for character in my_string:
 ... if (character == character.upper()) and (character !='@') and
 (character != '.'):
 ... my_string = my_string.replace(character,'')


 And the end result was john@hotmail.com.

 Is there a better way to do that ?

Instead of matching the ones that are the same as their uppercase
version, why not instead keep the ones that are the same as their
lowercase?

 email = 'removemejohn.dospames...@removemehotmail.com'
 ''.join(filter(lambda x: x==x.lower(),email))
'john@hotmail.com'

This could be a neat introduction to a functional style of code, if
you haven't already met it; use of filter and lambda expressions can
make for some beautifully expressive code.

 Also, what would in your opinion make it *harder* for a non-human
 to retrieve the original e-mail address? Maybe a function with no
 inverse function ? Generating an image that can't be converted back
 to text, etc..

Ah, now you're getting into the realm of CAPTCHAs. I'll be quite frank
with you: Don't bother. Many MANY experts are already looking into it
- with various levels of success. Spammers are getting better and
better at harvesting addresses and solving CAPTCHAs, and your legit
users aren't getting that benefit, so you make it harder for the
humans while still possible for the bots. (And some CAPTCHAs are
solved by simply farming the jobs off to actual human beings (in
China, I think I heard) for a pittance each. There's fundamentally no
way to prevent that.) So your options are:

1) Call on someone else's code. Search the internet for ways of
concealing email addresses, pick one that isn't too much hassle to
legit users, and use it. I've seen quite a few that put the email
address in an image, one way or another; they tend to be a bit
annoying, but some aren't too bad.

2) Give up on protecting your address, and protect your inbox instead.
Get some good spam filtering, and let 'em send it all at you. I run a
local mail server for a few domains, and even with the filter set
conservatively enough to all but eliminate false positives, we see
only a handful of false negatives (according to my logs, 182 emails
reported as spam this week, across all domains and all accounts - most
accounts see 10 a week, a couple of them see maybe 20-30). And again,
you can call on someone else to do the work for you - sending all your
mail to gmail lets you take advantage of their filtering, for
instance.

But hey. If you want to play around with text processing, Python's a
good choice for it!

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


Re: What minimum should a person know before saying I know Python

2013-09-20 Thread rusi
On Friday, September 20, 2013 7:09:13 PM UTC+5:30, Robert Kern wrote:
 On 2013-09-20 12:43, rusi wrote:
  Stroustrup says he is still learning C++ and I know kids who have no qualms 
  saying they know programming language L (for various values of L) after 
  hardly an hour or two of mostly advertising and pep-talk exposure.
 
  So without knowing what you mean my 'knowing' I am not going to try 
  answering q-1
 
 
 I think that's his actual question: What do *you* mean by 'I know Python'? 
 At what point in your Python career did you feel comfortable claiming that?

Hmm... Now you are putting me in a spot :-)
Too many aspects to this to give a reasonably short answer :-)
I'll try and collect my thoughts in due course...

What I meant to say to the OP:
Knowing a language can mean widely different things:
1. to crack interviews
2. as a junior programmer
3. as a tech-lead
4. for bug-fixing/maintaining others' code

A big difference between 1 and 2 is the value of obfuscated/ting code
For 1 knowing trick questions/answers is a big win; for 2 more likely a loss.
Also for 1 a big breath-first knowledge is required; for 2 its ok to know a 
subset well and be able to use it with good taste.

For 3 right emotions are more important than details -- to look at a 
significant piece of code and be accurate in exclaiming Wonderful/Blechhh

4 is really an important and much neglected mindset. Ive talked about it here

http://blog.languager.org/2010/02/service-and-product-mindsets.html

Ok... So trying to say (a little!) in answer to your (Robert's) question though 
tangentially.

Ive spent 20 years in a university.  Most of what goes on there may be called 
gaming.
- The best students are not the one's who know or love to know most but who 
successfully game the system
- The best teachers are not those who teach best but who are one-up on the 
students' gaming habits and tendencies
- The best administrators are those who are cleverest at using academic 
(sounding) jargon to make lucrative institutions

Sounds cynical?  Well most of the students are not the 'best students' above 
and so its more important to gauge where (s)he is coming from, where going etc 
and to answer appropriately rather than giving to-the-point answers when the 
student may be too bewildered to ask exact/precise questions.

Basically instruct him just enough on how to game the system so that he clears 
the course but not so much he loses his soul!
-- 
https://mail.python.org/mailman/listinfo/python-list


dynamic function parameters for **kwargs

2013-09-20 Thread bab mis
Hi ,
I have a function as below:

def func(**kwargs):
...
...




args=a='b',c='d'

i want to call func(args) so that my function call will take a var as an 
parameter.

it fails with an error typeError: fun() takes exactly 0 arguments (1 given) 

. Is there any other way to get the same.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: lambda - strange behavior

2013-09-20 Thread Rotwang

On 20/09/2013 16:21, Kasper Guldmann wrote:

I was playing around with lambda functions, but I cannot seem to fully grasp
them. I was running the script below in Python 2.7.5, and it doesn't do what
I want it to. Are lambda functions really supposed to work that way. How do
I make it work as I intend?

f = []
for n in range(5):
 f.append( lambda x: x*n )

assert( f[4](2) == 8 )
assert( f[3](3) == 9 )
assert( f[2](2) == 4 )
assert( f[1](8) == 8 )
assert( f[0](2) == 0 )


This is a common gotcha. In the function lambda x: x*n n is a global 
variable, which means that when the function is called it searches 
globals() for the current value of n, which is 4 (since that was its 
value when the for loop ended). There are several ways to define 
functions that depend on the values bound to names at creation time, 
like you're trying to do. One is to use the fact that default function 
arguments are evaluated when the function is created. So this will work:


f = []
for n in range(5):
f.append(lambda x, n = n: x*n)


Another is to use the fact that arguments passed in function calls are 
evaluated when the function is called. That means that you can define a 
function which takes a parameter as an argument and returns a function 
which depends on that parameter to get the desired behaviour, like this:


f = []
for n in range(5):
f.append((lambda n: lambda x: x*n)(n))
--
https://mail.python.org/mailman/listinfo/python-list


Re: What minimum should a person know before saying I know Python

2013-09-20 Thread Chris Angelico
On Sat, Sep 21, 2013 at 2:28 AM, Aseem Bansal asmbans...@gmail.com wrote:
 I hope that cleared some confusion about what I wanted to ask. I wanted to 
 gauge myself to find if I am progressing or not.

Well, based on my definition, that's easy to answer. Have you solved
problems using Python? If you have a bunch of HTML pages and you need
to get some info out of all of them by COB today, do you think I can
do that with Python, or do you think I can do that with sed, awk,
grep, and five levels of pipe? The tools you use for an urgent job
will be the ones you know.

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


Re: lambda - strange behavior

2013-09-20 Thread rusi
On Friday, September 20, 2013 8:51:20 PM UTC+5:30, Kasper Guldmann wrote:
 I was playing around with lambda functions, but I cannot seem to fully grasp
 them. I was running the script below in Python 2.7.5, and it doesn't do what
 I want it to. Are lambda functions really supposed to work that way. How do
 I make it work as I intend?
 
 f = []
 for n in range(5):
 f.append( lambda x: x*n )
 
 assert( f[4](2) == 8 )
 assert( f[3](3) == 9 )
 assert( f[2](2) == 4 )
 assert( f[1](8) == 8 )
 assert( f[0](2) == 0 )

You are not wrong in being surprised.  Here's the python rewritten in a more 
functional style

And then the same in haskell.

$ python3
Python 3.3.2+ (default, Jun 13 2013, 13:47:13) 
[GCC 4.8.1] on linux
Type help, copyright, credits or license for more information.
 fl= [lambda x: x + n for n in range(5)]
 [f(1) for f in fl]
[5, 5, 5, 5, 5]
 

---haskell-
$ ghci
GHCi, version 7.4.1: http://www.haskell.org/ghc/  :? for help

Prelude let fl = [\x- x+n | n - [0..4]] 
Prelude [f 1 | f - fl]
[1,2,3,4,5]
Prelude 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What minimum should a person know before saying I know Python

2013-09-20 Thread Aseem Bansal
By C being smaller than Python I did not mean the scope of C is lesser than 
Python. I simply meant that the standard libraries are less in number compared 
to Python.

By knowing Python I didn't imply an expert-level understanding. Minimum that so 
someone cannot say Hey, you said you knew Python but you don't know 
anything.. Something on these lines. You can say for cracking interviews 
and/or as a junior programmar and/or as a fresher getting into industry.

I like to have test cases for my functions/scripts but that wasn't what I had 
in my mind.

Also I am learning Python because it is faster to make things with it. Not 
because it is going to get me any marks or anything.

@Tim Chase
That list helped. I was looking for something like that. Questions which I can 
try to answer and see where I stand.

I hope that cleared some confusion about what I wanted to ask. I wanted to 
gauge myself to find if I am progressing or not.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Antispam measures circumventing

2013-09-20 Thread Chris Angelico
On Sat, Sep 21, 2013 at 2:23 AM, Jussi Piitulainen
jpiit...@ling.helsinki.fi wrote:
 (Put .invalid at the end, maybe. But I wish spam was against the law,
 effectively.)

Against what law, exactly? In what jurisdiction will you seek to
charge spammers? And who will track them down?

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


Re: lambda - strange behavior

2013-09-20 Thread Jussi Piitulainen
Kasper Guldmann writes:

 I was playing around with lambda functions, but I cannot seem to
 fully grasp them. I was running the script below in Python 2.7.5,
 and it doesn't do what I want it to. Are lambda functions really
 supposed to work that way. How do I make it work as I intend?
 
 f = []
 for n in range(5):
 f.append( lambda x: x*n )
 
 assert( f[4](2) == 8 )
 assert( f[3](3) == 9 )
 assert( f[2](2) == 4 )
 assert( f[1](8) == 8 )
 assert( f[0](2) == 0 )

It's not the lambda, it's the for. All five functions share the one n,
whose value the for changes in each iteration so that the last value
remains in force after the loop.

There's a trick: f.append( lambda x, n=n: x*n ). Now the lambda gets
to remember the value of the n of the for as the default value of its
own local n.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What minimum should a person know before saying I know Python

2013-09-20 Thread Mark Janssen
 I started Python 4 months ago. Largely self-study with use of Python 
 documentation, stackoverflow and google. I was thinking what is the minimum 
 that I must know before I can say that I know Python?

Interesting.  I would say that you must know the keywords, how to make
a Class, how to write a loop.  That covers about 85% of it.
-- 
MarkJ
Tacoma, Washington
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Antispam measures circumventing

2013-09-20 Thread Jussi Piitulainen
Jugurtha Hadjar writes:

 Supposing my name is John Doe and the e-mail is john@hotmail.com,
 my e-mail was written like this:
 
 removemejohn.dospames...@removemehotmail.com'
 
 With a note saying to remove the capital letters.
 
 Now, I wrote this :
 
 for character in my_string:
 ... if (character == character.upper()) and (character !='@') and
 (character != '.'):
 ... my_string = my_string.replace(character,'')

That does a lot of needless work, but I'll suggest other things
instead of expanding on this remark.

First, there's character.isupper() that will replace your entire
condition.

Second, there's ''.join(c for c in my_string if not c.isupper()).

 And the end result was john@hotmail.com.
 
 Is there a better way to do that ? Without using regular expressions
 (Looked *really* ugly and it doesn't really make sense, unlike the few
 lines I've written, which are obvious even to a beginner like me).

I don't see how you get to consider '[A-Z]' ugly. (Python doesn't seem
to have the named character classes like '[[:upper:]]' that would do
more than ASCII in some regexp systems. I only looked very briefly.)

Third, here's a way - try help(str.translate) and help(str.maketrans)
or python.org for some details:

  from string import ascii_uppercase
  'Ooh, CamelCase!'.translate(str.maketrans('', '', ascii_uppercase))
 'oh, amelase!'

 I obviously don't like SPAM, but I just thought If I were a spammer,
 how would I go about it.
 
 Eventually, some algorithm of detecting the
 johndotdoeathotmaildotcom must exist.
 
 Also, what would in your opinion make it *harder* for a non-human to
 retrieve the original e-mail address? Maybe a function with no
 inverse function ? Generating an image that can't be converted back
 to text, etc..

Something meaningful: make it john.doe...@hotmail.com with a note to
remove the female deer for john@hotmail.com, or remove the drop
of golden sun for john@hotmail.com. You may get a cease and
desist letter - much uglier than a simple regex - if you do literally
this, but you get the idea. I've seen people using remove the animal
or remove the roman numeral.

(Put .invalid at the end, maybe. But I wish spam was against the law,
effectively.)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: dynamic function parameters for **kwargs

2013-09-20 Thread stas poritskiy
On Friday, September 20, 2013 10:51:46 AM UTC-5, bab mis wrote:
 Hi ,
 
 I have a function as below:
 
 
 
 def func(**kwargs):
 
 ...
 
 ...
 
 
 
 
 
 
 
 
 
 args=a='b',c='d'
 
 
 
 i want to call func(args) so that my function call will take a var as an 
 parameter.
 
 
 
 it fails with an error typeError: fun() takes exactly 0 arguments (1 given) 
 
 
 
 . Is there any other way to get the same.

Hi, may be this will be useful to you:
http://simeonfranklin.com/blog/2012/jul/1/python-decorators-in-12-steps/

Go to Section 11 in the document.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Antispam measures circumventing

2013-09-20 Thread Jugurtha Hadjar

Chris, Vlastimil, great insights gentlemen! Thanks

Chris Angelico wrote:

Instead of matching the ones that are the same as their uppercase
version, why not instead keep the ones that are the same as their
lowercase?


That's why I started off doing, and then lost track a bit. It didn't 
cross my mind that '.' and '@' are uncased characters and I'm a bit 
ashamed of not thinking about that before running the code


(i.e:

'.'.lower() gives False
'.'.upper() gives False

And the same for '@'. So unless you specifically spare them, they'll 
be whacked if you exclude upper case characters, or only include lower 
case characters).


Ah, now you're getting into the realm of CAPTCHAs. I'll be quite frank
with you: Don't bother. Many MANY experts are already looking into it

Yeah.. I thought of writing My e-mail is my first name, dot, my last 
name at gmail dot com.


Some riddling can be viable to a certain extent. Or if your e-mail is 
ba86rocks...@gm.bu


ba, then 86, then rock, then star, at gm dot bu.

Or the e-mail can be generated dynamically calling a script that 
assembles pieces and displays it. This way, it can escape scrapers and 
all and will make it hard to manually harvest e-mails.. Which brings us 
to your next point about e-mail harvesters and that kind of labor (which 
is astounding !).





 email = 'removemejohn.dospames...@removemehotmail.com'
 ''.join(filter(lambda x: x==x.lower(),email))
'john@hotmail.com'

Nice ! As well as Vlastimil's suggestions. The things I found on the net 
weren't that well written. There were *way* too many lines that made me 
think No way. There's gotta be a better way.







--
~Jugurtha Hadjar,
--
https://mail.python.org/mailman/listinfo/python-list


Re: dynamic function parameters for **kwargs

2013-09-20 Thread Rotwang

On 20/09/2013 16:51, bab mis wrote:

Hi ,
I have a function as below:

def func(**kwargs):
 ...
 ...




args=a='b',c='d'

i want to call func(args) so that my function call will take a var as an 
parameter.
it fails with an error typeError: fun() takes exactly 0 arguments (1 given)
. Is there any other way to get the same.


It fails because args is a string and func(args) is passing a single 
string as a positional argument to func, rather than passing the keyword 
arguments a and c. Not sure if I've understood your question, but


args = {'a': 'b', 'c': 'd'}
# or equivalently args = dict(a='b', c='d')
func(**args)

will work. If you need args to be a string like the one in your post 
then you could try


eval('func(%s)' % args)

or

func(**eval('dict(%s)' % args))

but that's only something that should be done if you trust the user who 
will decide what args is (since malicious code passed to eval() can do 
pretty much anything).

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


Re: Making it a MultiThread!

2013-09-20 Thread stas poritskiy
On Friday, September 20, 2013 7:56:16 AM UTC-5, stas poritskiy wrote:
 Hello All!
 
 
 
 I have a general question, 
 
 i was posting here earlier while trying to troubleshoot a few things while 
 developing an application, i was able to hit all of my goals, and make things 
 work! Thank you all who contributed to my research, and again, sorry for poor 
 formatting of the threads, i am slowly learning;)
 
 
 
 I am working on integration of multiple GUI (Tkinter) elements, such a 
 progress bar, label update, etc, and throughout my research i discovered that 
 i need to have Threading modules used to distribute the calls for GUI update 
 and processing of my main App.
 
 
 
 My Application is broken into multiple Classes(modules), and i wanted to hear 
 your thought on the best practices to implement the Threading model.
 
 
 
 I was thinking to create a new py-module, and reference all other 
 modules/class to it, and create thread.start() objects, that would execute 
 the GUI part, other will handle GUI Updates, and other - will be doing the 
 processing.
 
 
 
 Please share some of your thought on this approach, or maybe you may suggest 
 a more effective way.
 
 thanks !

Here is some CODE that i wrote to present the working case.
my main program is split in multiple modules, but this structure should 
represent what i am trying to get.

module name: multiProcessLauncher.py

import multiprocessing
import gui

def main():
jobs = []
p = multiprocessing.Process(target=gui.basicGui)
jobs.append(p)
p.start()

if __name__ == '__main__':
main()
pass


Module Name: gui.py

from Tkinter import *
import tkMessageBox
import Tkinter
import multiProcessLauncher
import action

def basicGui():
g = action.Action()
print GUI
processor = multiProcessLauncher
name = processor.multiprocessing.current_process().name
print name, starting
print name, exiting
  
top = Tk()
button = Button(top, text = Press Me, command = g.do_something)
button.pack()
top.mainloop()

def main():
pass
if __name__ == __main__:
main()

Module Name: action.py

class Action(object):
def __init__(self):
self.text = Running Action
def do_something(self):
print self.text

i am trying to figure out how to make use of multiprocessing access the PRINT 
from the action.py using the GUI button. if you run the code and press the 
button, the console will read nothing, but as soon as you close the GUI, it 
spits out the text to console. I read about using Que, but i am not sure how to 
implement, could someone suggest how? thank you
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Antispam measures circumventing

2013-09-20 Thread Chris Angelico
On Sat, Sep 21, 2013 at 2:23 AM, Jussi Piitulainen
jpiit...@ling.helsinki.fi wrote:
 Something meaningful: make it john.doe...@hotmail.com with a note to
 remove the female deer for john@hotmail.com, or remove the drop
 of golden sun for john@hotmail.com.

This method can be quite effective. In fact, of all the suggestions
made so far, I'd say these are a few of my favorite techniques...

*ducks the rotten tomatoes*

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


matplotlib question: OverflowError: Allocated too many blocks

2013-09-20 Thread Ray
hi,
i'm using matplotlib to generate chart from audio wave file, and I had a 
problem with it.

test code as:

from scipy.io import wavfile
import matplotlib.pyplot as plt
rate, x = wavfile.read('test2.wav')
plt.plot(x)
plt.savefig('test2.png')

the len of x= 19531840 (as len(x) )
matplotlib give exception: OverflowError: Allocated too many blocks

if I display it by:
plt.draw()
plt.show()

everything works fine. it seems I just can't save the output to a file. 
I know if I reduce the figsize would make it work. [aka 
plt.subplots(figsize=(5,2)) ] but this is not what I need. I need to generate 
the large chart. (depends on size of input file)

anyone know if there's another way to save big output file?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What minimum should a person know before saying I know Python

2013-09-20 Thread Jugurtha Hadjar
I think it is a philosophical question. It's like saying I know maths, 
which is a ridiculous phrase I was surprised to hear, let alone 
surprised to hear often.


Can someone know everything there is to know about something ? I doubt 
it. The point, at least for me, isn't to know everything .. But the 
ability to find out.


I consider myself ignorant in almost everything, that's because I ask 
myself a lot of questions about a lot of things I ignore. The point is 
following up and looking things up so that you know them.


I knew many things I wasn't even aware existed. What this (constant 
questions) does is that it gives a lot of information that is networked 
(and you make a lot of connections between seemingly unrelated topics).


I'll give an example: I had a class in my second year in college about 
nuclear and atomic physics. There was a chapter about the Doppler 
effect. I was able to grasp it easily, because when I was a kid, it 
happened I took magazines in the bathroom to read, and I've read about it.


Having a déjà-vu impression in a lot of things and to be able to make 
analogies of concepts and principles has helped me tremendously. When I 
got into college and started programming PIC microcontrollers, having 
tinkered with Intel assembly language in high-school (disassembling 
executables and tinkering with them) was definitely a plus (Registers, 
operands, carry operations, hexadecimal, addresses).


When in the first year we started Pascal, I already did things in Delphi 
when I was in high-school. But then again, I also did tinker with C in 
middle-school (really basic stuff) and BASIC as a child.




Do I know Python ? No. I don't think I ever will. But I am confident I 
will be able to do what I cannot do right now, and the complexity of the 
things I will be able to do will increase, as will my ability to 
simplify complex things.



It's a converging exponential, as a capacitor charging. The goal is to 
minimized the time constant so you get at about 63.2% fast. The 
incremental 1%s will take years and I don't think you'll ever hit 100%, 
not even after decades. Sorry :)





--
~Jugurtha Hadjar,
--
https://mail.python.org/mailman/listinfo/python-list


building an online judge to evaluate Python programs

2013-09-20 Thread Jabba Laci
Hi,

In our school I have an introductory Python course. I have collected a
large list of exercises for the students and I would like them to be
able to test their solutions with an online judge (
http://en.wikipedia.org/wiki/Online_judge ). At the moment I have a
very simple web application that is similar to Project Euler: you
provide the ID of the exercise and the output of the program, and it
tells you if it's correct or not. However, it can only be used with
programs that produce an output (usually a short string or a number).

In the next step I would like to do the following. The user can upload
his/her script, and the system tests it with various inputs and tells
you if it's OK or not (like checkio.org for instance). How to get
started with this?

There are several questions:
* What is someone sends an infinite loop? There should be a time limit.
* What is someone sends a malicious code? The script should be run in a sandbox.

All tips are appreciated.

Thanks,

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


Re: What minimum should a person know before saying I know Python

2013-09-20 Thread Aseem Bansal
On Friday, September 20, 2013 10:04:32 PM UTC+5:30, Chris Angelico wrote:
 On Sat, Sep 21, 2013 at 2:28 AM, Aseem Bansal asmbans...@gmail.com wrote:
  I hope that cleared some confusion about what I wanted to ask. I wanted to 
  gauge myself to find if I am progressing or not.
 
 Well, based on my definition, that's easy to answer. Have you solved
 problems using Python? If you have a bunch of HTML pages and you need
 to get some info out of all of them by COB today, do you think I can
 do that with Python, or do you think I can do that with sed, awk,
 grep, and five levels of pipe? The tools you use for an urgent job
 will be the ones you know.
 
 ChrisA

Yeah I have. I needed to get stats from the front page of a website. I wrote a 
script for that. I plotted the stats using matplotlib. I collected data 
manually and missed running the script one day so I took care of that problem 
using Python. Wrote a script that checked for internet connectivity and then 
ran the scripts that downloaded the stuff I needed and then placed this script 
in the Windows startup folder. 

That was a nice feeling. Because I can just customize that startup script if I 
ever wanted to change my computer's startup behaviour.

But that was pure luck that I had done the random example that you had chosen. 
It would be difficult to find my overall progress by the one thing.

I am currently unemployed so the sense of urgency isn't there normally. That's 
why I asked this question. But I got your point.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What minimum should a person know before saying I know Python

2013-09-20 Thread Aseem Bansal
I understand that being able to solve problems and knowing when to use 
something is the final measure of knowing something properly. 

But I wanted to find something quantitative that I can use to measure myself. 
Like the interview questions that Tim Chase posted.

Measuring myself based on the problems that I can think of is like a small 
child saying I know that 1 + 1 = 2. So I know maths. That may be the toughest 
problem that he can think of. That isn't a correct evaluation of his math 
abilities. Similarly measuring myself on the basis of the problems that I can 
think of and solve doesn't actually measure anything.

I don't want to be living in a fool's paradise based on solving the problems I 
can solve. It is not being able to solve a problem that will make me realize my 
limits.

That's why I asked this question... I am kind of asking for advice.
-- 
https://mail.python.org/mailman/listinfo/python-list


pyGTK Help Needed Please

2013-09-20 Thread bingefeller
Hi folks,

I'm trying to run a program called Nicotine+ on my Mac which is running 10.8.5. 
Nicotine+ requires GTK2, pyGTK2 and Python to run. I believe I have all of 
these installed via Macports (please see here - http://pastebin.com/nwmrpp2Y )

When I try to run Nicotine+ I get this message:

'/Users/**/Downloads/nicotine+-1.2.16', 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
 
'/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
 
'/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC',
 '/Library/Python/2.7/site-packages']
Exception: No module named pygtk


If I run Python and type import pygtk I get this message:

Traceback (most recent call last):
File stdin, line 1, in module
ImportError: No module named pygtk


can anyone help me please?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python GUI?

2013-09-20 Thread Metallicow
On Wednesday, September 11, 2013 3:55:59 PM UTC-5, Eamonn Rea wrote:
 There are a few known GUI toolkits out there, and the main ones from what I 
 can tell are:
 
 
 
 Tkinter -- Simple to use, but limited
 
 PyQT -- You have a GUI designer, so I'm not going to count that
 
 PyGTK -- Gnome officially back this I think
 
 wxPython -- Very nice, very professional, approved by Python creator, but 
 alas hard to get started with
 
 
 
 So, what are your personal preferences and why? Why use X over Y?
 
 
 
 I, personally, really like wxPython, but I also really like Tkinter. I've 
 messed with PyGTK, but I'd choose wxPython over it.
 
 
 
 Have you got anything to say on what one I should be using(excluding PyQT 
 because it has a DD designer :( )? Is Tkinter really dead? Should I stick 
 with wxPython?
 
 
 
 It's might be similar to the What language to use argument, or the What 
 background to code on argument(I prefer darker backgrounds xD Please don't 
 argue about this though!), in the sense that there is *no* answer, just 
 preference.
 

I prefer wx over qt for these reasons.
Robin works for qt now. *Funny isn't it...*
Basically, To change qt(PySide) you need to pretty much need to be employed by 
qt, not the case with wx(is not a *For profit*, but you can donate.).
In my opinion, in the long run(foreseeing from this point forward)
wx will win, because anybody can create a popular fork. And if it is good 
enough, it might get accepted into the standard dist also.

As far as mature, well, the previous statement shows that he can make money 
doing it also and enjoy doing what he does in his spare time. I believe Guido 
has the privilege of spending half of his time At work and getting paid for 
it. on python.
And Project Phoenix(Py2/3) is still on the way. We'll revisit this question 
next year.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: building an online judge to evaluate Python programs

2013-09-20 Thread Aseem Bansal
However, it can only be used with programs that produce an output

Just interested, what else are you thinking of checking?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: building an online judge to evaluate Python programs

2013-09-20 Thread Jabba Laci
Let's take this simple exercise:

Write a function that receives a list and decides whether the list is
sorted or not.

Here the output of the function is either True or False, so I cannot
test it with my current method.

Laszlo

On Fri, Sep 20, 2013 at 7:57 PM, Aseem Bansal asmbans...@gmail.com wrote:
However, it can only be used with programs that produce an output

 Just interested, what else are you thinking of checking?
 --
 https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Antispam measures circumventing

2013-09-20 Thread Joel Goldstick
On Fri, Sep 20, 2013 at 12:45 PM, Jugurtha Hadjar jugurtha.had...@gmail.com
 wrote:

 Chris, Vlastimil, great insights gentlemen! Thanks


 Chris Angelico wrote:

 Instead of matching the ones that are the same as their uppercase
 version, why not instead keep the ones that are the same as their
 lowercase?


 That's why I started off doing, and then lost track a bit. It didn't cross
 my mind that '.' and '@' are uncased characters and I'm a bit ashamed of
 not thinking about that before running the code

 (i.e:

 '.'.lower() gives False
 '.'.upper() gives False

 And the same for '@'. So unless you specifically spare them, they'll be
 whacked if you exclude upper case characters, or only include lower case
 characters).


 Ah, now you're getting into the realm of CAPTCHAs. I'll be quite frank
 with you: Don't bother. Many MANY experts are already looking into it

 Yeah.. I thought of writing My e-mail is my first name, dot, my last name
 at gmail dot com.

 Some riddling can be viable to a certain extent. Or if your e-mail is
 ba86rocks...@gm.bu

 ba, then 86, then rock, then star, at gm dot bu.

 Or the e-mail can be generated dynamically calling a script that assembles
 pieces and displays it. This way, it can escape scrapers and all and will
 make it hard to manually harvest e-mails.. Which brings us to your next
 point about e-mail harvesters and that kind of labor (which is astounding
 !).





  email = 'REMOVEMEjohn.doSPAMeSPAM@**REMOVEMEhotmail.com'
  ''.join(filter(lambda x: x==x.lower(),email))
 'john@hotmail.com'

 Nice ! As well as Vlastimil's suggestions. The things I found on the net
 weren't that well written. There were *way* too many lines that made me
 think No way. There's gotta be a better way.







 --
 ~Jugurtha Hadjar,
 --
 https://mail.python.org/**mailman/listinfo/python-listhttps://mail.python.org/mailman/listinfo/python-list


Last year I was playing around with django forms and wrote some code that
required the user to add some numbers before the form was submitted. Here
is the article: http://www.joelgoldstick.com/blog/2012/sep/30/django-forms/

This isn't exactly what you are asking, but it does give you a change to
let someone send you mail without giving out your email address.

With the onslaught of social media stuff, it feels like sites like linked
in and anything that uses gmail want to get you to give away your email
address, and perhaps give access to everyone in your lists. So, I'm
suggesting its really a loosing battle.

-- 
Joel Goldstick
http://joelgoldstick.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: building an online judge to evaluate Python programs

2013-09-20 Thread John Gordon
In mailman.196.1379702349.18130.python-l...@python.org Jabba Laci 
jabba.l...@gmail.com writes:

 Let's take this simple exercise:

 Write a function that receives a list and decides whether the list is
 sorted or not.

 Here the output of the function is either True or False, so I cannot
 test it with my current method.

Make a master input file and a master output file for each exercise.  If
the student program's output matches the master output when run from the
master input, then it is correct.

-- 
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, The Gashlycrumb Tinies

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


Re: Python GUI?

2013-09-20 Thread Michael Torrie
On 09/20/2013 12:34 PM, Metallicow wrote:
 I prefer wx over qt for these reasons. Robin works for qt now. *Funny
 isn't it...* Basically, To change qt(PySide) you need to pretty much
 need to be employed by qt, not the case with wx(is not a *For
 profit*, but you can donate.). In my opinion, in the long
 run(foreseeing from this point forward) wx will win, because anybody
 can create a popular fork. And if it is good enough, it might get
 accepted into the standard dist also.

Qt is not a company. Qt is an open source project owned and sponsored by
Digia and also Nokia, though Nokia's participation will probably be
reduced now that Microsoft has bought Nokia.  Two years ago, at least,
lots of code commits came from outside Nokia.  Now, PySide was
originally a Nokia project when they owned Qt, and I know they did have
contributions from the community.  I don't see any evidence things have
changed.

Your logical reasoning is certainly faulty on one point, however. Why
would you claim wx is forkable but PySide (or even Qt) is not?

Both are completely open source and free software (as in LGPL).


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


Re: Python GUI?

2013-09-20 Thread Metallicow
Sorry about that, nokia is/was.
qt was developed(IIRC) for phones. Someone made money. And a lot of it.
wx is a more or less a free project.
I don't use a phone anymore. If I had a touch screen phone and was a developer, 
I still wouldn't use one. I have my many reasons why...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: building an online judge to evaluate Python programs

2013-09-20 Thread Jabba Laci
 That last seems to me to be the biggie.  Several times in the past few
 years, people in this mailing list have tried to build a safe sandbox.
 And each one was a big failure, for a hacker of sufficient interest.
 Some of them were spectacular failures.

 If you have to be safe from your user, Python may be the wrong language
 to give them.

Well, the course is about Python and I want to test Python scripts...

I've heard about chroot jail but I never used it. Wikipedia says:

A chroot on Unix operating systems is an operation that changes the
apparent root directory for the current running process and its
children. A program that is run in such a modified environment cannot
name (and therefore normally not access) files outside the designated
directory tree. The term chroot may refer to the chroot(2) system
call or the chroot(8) wrapper program. The modified environment is
called a chroot jail.

I guess it could be used for sandboxing.

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


Re: building an online judge to evaluate Python programs

2013-09-20 Thread John Gordon
In mailman.195.1379698177.18130.python-l...@python.org Jabba Laci 
jabba.l...@gmail.com writes:

 There are several questions:
 * What is someone sends an infinite loop? There should be a time limit.

You could run the judge as a background process, and kill it after ten
seconds if it hasn't finished.

 * What is someone sends a malicious code? The script should be run in a
 sandbox.

You could run the judge from its own account that doesn't have access to
anything else.  For extra security, make the judge program itself owned by
a separate account (but readable/executable by the judge account.)

I suppose you'd have to disable mail access from the judge account too.
Not sure how to easily do that.

-- 
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, The Gashlycrumb Tinies

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


Iterate through a list of tuples for processing

2013-09-20 Thread Shyam Parimal Katti
I have a list of tuples where the number of rows in the list and the number
of columns in tuples of the list will not be constant. i.e.



list = [(a1,b1, …z1), (a2,b2, …, z2),…. ,(am,bm, … , zm )]. It can be
compared to the SQL results, as the number of columns change in the sql,
the number of columns change in the list of tuples as well.



I have to iterate through each element of each tuple in the list, perform
some checks on the value, convert it and return the modified values as a
new list of tuples.



i.e.

list_value = [(‘name1’, 1234, ‘address1’ ), (‘name2’, 5678, ‘address2’),
(‘name3’, 1011, ‘addre”ss3’)]



I need to access each value to check if the value contains a double quote
and enclose the string containing double quote with double quotes. The
transformation should return



list_value = [(‘name1’, 1234, ‘address1’ ), (‘name2’, 5678, ‘address2’),
(‘name3’, 1011, ‘”addre”ss3”’)]



The simplest approach for me would be to do this:



mod_val = [transform(row) for row in list_value]



def transform(row):

   mod_list=[]

   while index  len(row):

...if isinstance(row[index],basestring):

...   if '' in row[index]:

...  mod_list.append(''+row[index]+'')

...else:

...   mod_list.append(row[index])

...index = index+1

... return mod_list





Is there a way to make the code concise using list comprehension?
-- 
https://mail.python.org/mailman/listinfo/python-list


Print statement not printing as it suppose to

2013-09-20 Thread Sam
hi everybody i am just starting to learn python, i was writing a simple i/o 
program but my print statement is acting weird. here is my code i want to know 
why it prints this way. thank you


car=int(input(Lamborghini tune-up:))

rent=int(input('\nManhatan apartment: '))

gifts=int(input('\nRandom Gifts: '))

total=car+rent+gifts

print(\nThe total amount required is , total )


OUTPUT

Lamborghini tune-up:1000

Manhatan apartment: 2300

Random Gifts: 234
('\nThe total amount required is ', 3534)



=== the problem is obviously on the last print statement that is supposed to 
print the outut
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Print statement not printing as it suppose to

2013-09-20 Thread Tim Delaney
On 21 September 2013 07:57, Sam anasdah...@gmail.com wrote:

 hi everybody i am just starting to learn python, i was writing a simple
 i/o program but my print statement is acting weird. here is my code i want
 to know why it prints this way. thank you

 print(\nThe total amount required is , total )


 OUTPUT

 ('\nThe total amount required is ', 3534)

 === the problem is obviously on the last print statement that is supposed
 to print the outut


Check your version of Python. The output you have given says that you're
using a Python 2 version, but the print syntax you're using is for Python
3. Unfortunately, you've hit one of the edge cases where they produce
different output.

As a general rule, either use % formatting or format()to produce a single
string to print, rather than relying on print to output them correctly for
you (or using string concatenation). Since you're only just starting you
won't have got to them yet - the simplest way to to it is to just insert
the string representation of all parameters. The above done using %
formatting would be:

print(\nThe total amount required is  %s % (total,))

which will produce the same output on both Python 2 and Python 3. Note the
double space before %s - that matches your print statement (there would be
soft-space inserted in your print statement, which is another reason not to
rely on print for anything other than single strings). If you didn't want
that extra space, it's easy to delete.

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


Re: Print statement not printing as it suppose to

2013-09-20 Thread Emiliano Carlos de Moraes Firmino
Remove both brackets in last line, You are creating a tuple in last
statement not making a function call.


2013/9/20 Sam anasdah...@gmail.com

 hi everybody i am just starting to learn python, i was writing a simple
 i/o program but my print statement is acting weird. here is my code i want
 to know why it prints this way. thank you


 car=int(input(Lamborghini tune-up:))

 rent=int(input('\nManhatan apartment: '))

 gifts=int(input('\nRandom Gifts: '))

 total=car+rent+gifts

 print(\nThe total amount required is , total )


 OUTPUT

 Lamborghini tune-up:1000

 Manhatan apartment: 2300

 Random Gifts: 234
 ('\nThe total amount required is ', 3534)



 === the problem is obviously on the last print statement that is supposed
 to print the outut
 --
 https://mail.python.org/mailman/listinfo/python-list




-- 
Emiliano Carlos de Moraes Firmino
Desenvolvedor | PMT | INdT
Universitário | Engenharia da Computação | UEA
emiliano.firm...@gmail.com | (92) 9196-3922
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Print statement not printing as it suppose to

2013-09-20 Thread John Gordon
In 05bbf1a3-6480-48ee-8984-2482b90c7...@googlegroups.com Sam 
anasdah...@gmail.com writes:

 print(\nThe total amount required is , total )

 OUTPUT

 ('\nThe total amount required is ', 3534)

In older versions of python (like the one you are using), 'print' is a
statement instead of a function.

In other words, it is used like this:

name = Bob
print Hello , name

Because there are parentheses around the text to be printed, your version
of python is interpreting it as a tuple.  Remove the parentheses and you
should be ok.

-- 
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, The Gashlycrumb Tinies

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


Re: What minimum should a person know before saying I know Python

2013-09-20 Thread Terry Reedy

On 9/20/2013 5:58 AM, Aseem Bansal wrote:

I started Python 4 months ago. Largely self-study with use of Python
documentation, stackoverflow and google. I was thinking what is the
minimum that I must know before I can say that I know Python?

I come from a C background which is comparatively smaller. But as
Python is comparatively much larger what minimum should I know?


The C stdlib may be smaller than the Python stdlib, but I do not think 
the language itself is much smaller. Python3 is a bit smaller than 
Python2 due to removals.


Python the language is defined in the Language Reference. So 'knowing 
Python' means knowing most of that. What I might leave out: the details 
of all the special method names; which bitwise operators do what; yield 
from (3.3+). From the library manual, I would include an overview of 
chapters 2 to 5. For instance, not memorize all the exceptions, but 
understand the hierarchy.


--
Terry Jan Reedy

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


Re: building an online judge to evaluate Python programs

2013-09-20 Thread Terry Reedy

On 9/20/2013 4:04 PM, Jabba Laci wrote:

That last seems to me to be the biggie.  Several times in the past few
years, people in this mailing list have tried to build a safe sandbox.
And each one was a big failure, for a hacker of sufficient interest.
Some of them were spectacular failures.

If you have to be safe from your user, Python may be the wrong language
to give them.


Well, the course is about Python and I want to test Python scripts...

I've heard about chroot jail but I never used it. Wikipedia says:

A chroot on Unix operating systems is an operation that changes the
apparent root directory for the current running process and its
children. A program that is run in such a modified environment cannot
name (and therefore normally not access) files outside the designated
directory tree. The term chroot may refer to the chroot(2) system
call or the chroot(8) wrapper program. The modified environment is
called a chroot jail.

I guess it could be used for sandboxing.


Perhaps running in a virtual environment helps. 3.3 comes with venv, 
which I believe is a version of virtualenv or something.


--
Terry Jan Reedy

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


Re: building an online judge to evaluate Python programs

2013-09-20 Thread Jabba Laci
I just found Docker ( http://docs.docker.io/en/latest/faq/ ). It seems
sandboxing could be done with this easily.

Laszlo

On Fri, Sep 20, 2013 at 10:08 PM, John Gordon gor...@panix.com wrote:
 In mailman.195.1379698177.18130.python-l...@python.org Jabba Laci 
 jabba.l...@gmail.com writes:

 There are several questions:
 * What is someone sends an infinite loop? There should be a time limit.

 You could run the judge as a background process, and kill it after ten
 seconds if it hasn't finished.

 * What is someone sends a malicious code? The script should be run in a
 sandbox.

 You could run the judge from its own account that doesn't have access to
 anything else.  For extra security, make the judge program itself owned by
 a separate account (but readable/executable by the judge account.)

 I suppose you'd have to disable mail access from the judge account too.
 Not sure how to easily do that.

 --
 John Gordon   A is for Amy, who fell down the stairs
 gor...@panix.com  B is for Basil, assaulted by bears
 -- Edward Gorey, The Gashlycrumb Tinies

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


Re: building an online judge to evaluate Python programs

2013-09-20 Thread Ned Batchelder

On 9/20/13 6:26 PM, Jabba Laci wrote:

I just found Docker ( http://docs.docker.io/en/latest/faq/ ). It seems
sandboxing could be done with this easily.


At edX, I wrote CodeJail (https://github.com/edx/codejail) to use 
AppArmor to run Python securely.


For grading Python programs, we use a unit-test like series of 
challenges.  The student writes problems as functions (or classes), and 
we execute them with unit tests (not literally unittest, but a similar 
idea).  We also tokenize the code to check for simple things like, did 
you use a while loop when the requirement was to write a recursive 
function.  The grading code is not open-source, unfortunately, because 
it is part of the MIT courseware.


--Ned.

Laszlo

On Fri, Sep 20, 2013 at 10:08 PM, John Gordon gor...@panix.com wrote:

In mailman.195.1379698177.18130.python-l...@python.org Jabba Laci 
jabba.l...@gmail.com writes:


There are several questions:
* What is someone sends an infinite loop? There should be a time limit.

You could run the judge as a background process, and kill it after ten
seconds if it hasn't finished.


* What is someone sends a malicious code? The script should be run in a
sandbox.

You could run the judge from its own account that doesn't have access to
anything else.  For extra security, make the judge program itself owned by
a separate account (but readable/executable by the judge account.)

I suppose you'd have to disable mail access from the judge account too.
Not sure how to easily do that.

--
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
 -- Edward Gorey, The Gashlycrumb Tinies

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


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


Re: Python GUI?

2013-09-20 Thread Michael Torrie
On 09/20/2013 01:58 PM, Metallicow wrote:
 Sorry about that, nokia is/was. qt was developed(IIRC) for phones.
 Someone made money. And a lot of it. wx is a more or less a free
 project. I don't use a phone anymore. If I had a touch screen phone
 and was a developer, I still wouldn't use one. I have my many reasons
 why...

Qt was first available back in 1995 from TrollTech, Inc.  Qt was always
about a good cross-platform UI toolkit that made it possible to develop
rich apps on Windows, Linux, and Mac.  Qt was one of the very first
modern GUI toolkits available on Linux.  I used KDE 1.0, which was based
on Qt back in 1998, long before cell phones with touch screens! In fact
I owe the KDE and Qt developers a debt of gratitude because KDE 1.0 was
really the first desktop that was usable to me as a Windows 95 refuge.
Moved to Linux and haven't looked back.

Qt only recently got touch stuff added, that make it work on phones and
tablets.  And the same touch stuff is going into GTK+, and I'm sure wx
will get it too soon, if they want to stay relevant.

And yes someone made money on Qt back in the day, as the company
TrollTech developed and marketed the toolkit for many years.  Back in
the 90s, a dispute over the open source licensing of the Qt source code
led to the creation of the Gnome project and desktop, using what became
known as the Gtk+ library.  Now, however, Qt is under the LGPL so it's
both free and open source in every way, and we are essentially reaping
the rewards of a very long and expensive development history, all for
free!  Whether it was generosity or desperation, it does not matter.

So I'm guessing you don't use Linux either, since people including Linus
Torvalds have become rich developing Linux.  Most linux development and
even governance is under the auspices of some for-profit companies.  Yet
it flourishes and has remained a free and open OS, thanks to Torvalds'
foresight to choose the GPL as the license for the kernel, which evens
the playing field and regulates the corporate influence.

Sounds to me like you've never used Qt in any of its versions.  I have
used Qt, GTK+, and wx, and they are all fine toolkits.  My current
preference is GTK+.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Iterate through a list of tuples for processing

2013-09-20 Thread Vlastimil Brom
2013/9/20 Shyam Parimal Katti spk...@nyu.edu:
 I have a list of tuples where the number of rows in the list and the number
 of columns in tuples of the list will not be constant. i.e.

  ... i.e.

 list_value = [(‘name1’, 1234, ‘address1’ ), (‘name2’, 5678, ‘address2’),
 (‘name3’, 1011, ‘addre”ss3’)]

 I need to access each value to check if the value contains a double quote
 and enclose the string containing double quote with double quotes. The
 transformation should return

 list_value = [(‘name1’, 1234, ‘address1’ ), (‘name2’, 5678, ‘address2’),
 (‘name3’, 1011, ‘”addre”ss3”’)]

  ...


 Is there a way to make the code concise using list comprehension?


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


Hi,
would the following do, what you want?

 orig_list = [('name1', 1234, 'address1' ), ('name2', 5678, 'address2'), 
 ('name3', 1011, 'address3')]
 modif_list = [[''+elem+'' if isinstance(elem, basestring) and '' in elem 
 else elem for elem in row] for row in orig_list]
 modif_list
[['name1', 1234, 'address1'], ['name2', 5678, 'address2'], ['name3',
1011, 'address3']]


I guess, you don't mind changing the inner tuples to lists, but the
original structure could be retained as well:
 [tuple([''+elem+'' if isinstance(elem, basestring) and '' in elem else 
 elem for elem in row]) for row in orig_list]
[('name1', 1234, 'address1'), ('name2', 5678, 'address2'), ('name3',
1011, 'address3')]


Of course, you have to decide, whether the readability/conciseness
suits your needs ...

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


Re: building an online judge to evaluate Python programs

2013-09-20 Thread Dave Angel
On 20/9/2013 13:28, Jabba Laci wrote:

 Hi,

 In our school I have an introductory Python course. I have collected a
 large list of exercises for the students and I would like them to be
 able to test their solutions with an online judge (
 http://en.wikipedia.org/wiki/Online_judge ). At the moment I have a
 very simple web application that is similar to Project Euler: you
 provide the ID of the exercise and the output of the program, and it
 tells you if it's correct or not. However, it can only be used with
 programs that produce an output (usually a short string or a number).

 In the next step I would like to do the following. The user can upload
 his/her script, and the system tests it with various inputs and tells
 you if it's OK or not (like checkio.org for instance). How to get
 started with this?

 There are several questions:
 * What is someone sends an infinite loop? There should be a time limit.
 * What is someone sends a malicious code? The script should be run in a 
 sandbox.


That last seems to me to be the biggie.  Several times in the past few
years, people in this mailing list have tried to build a safe sandbox.
And each one was a big failure, for a hacker of sufficient interest.
Some of them were spectacular failures.

If you have to be safe from your user, Python may be the wrong language
to give them.


-- 
DaveA

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


Re: Python GUI?

2013-09-20 Thread Robert Kern

On 2013-09-20 19:34, Metallicow wrote:


I prefer wx over qt for these reasons.
Robin works for qt now. *Funny isn't it...*


Lying about someone's employment is not very funny. Robin does not work for Qt 
or even Digia, the nearest thing to a corporate owner of Qt these days.


  https://www.enthought.com/company/team/devs/


Basically, To change qt(PySide) you need to pretty much need to be employed by 
qt,


This is emphatically incorrect, by your own example. Robin does indeed 
contribute to the PySide project. Both Qt and PySide are both open to and 
*driven by* contributions from the community.


  http://qt-project.org/contribute
  http://qt-project.org/wiki/PySideContributors

--
Robert Kern

I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth.
  -- Umberto Eco

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


Re: mutlifile inheritance problem

2013-09-20 Thread Peter Cacioppi
On Thursday, March 21, 2002 2:03:23 PM UTC-7, Marc wrote:
 I have classes defined in different files and would like to inherit
 from a class in file A.py for a class in file B.py but am running into
 problems.  I'm using Python 1.5.2 on Windows NT
 
 Here's a specific example:
 
 
 file cbase01.py:
 
 class CBase:
 
 def __init__(self):
 self.cclass = None
 print cbase
 
 class CImStream(CBase):
 
 def __init(self):
 CBase.__init__(self)
 print CImStream
 
 *
 in file wrappers_A01.py: 
 
 import cbase01
 reload(cbase01)
 
 class ImStream_SavedBitmaps(cbase01.CImStream):
 
 def __init__(self):
 cbase.CImStream.__init__(self)
 print SavedBitmaps
 
 **
 in file sequencer01.py
 
 import cbase01# the offending lines, program works 
 reload(cbase01)   # if I comment these out.
 
 class Sequencer:
 
 def Append(self, item):
 pass
 
 *
 in test02.py
 
 import wrappers_A01
 reload(wrappers_A01)
 
 import sequencer01
 reload(sequencer01)
 
 x0 = wrappers_A01.ImStream_SavedBitmaps()
 ***
 
 If I run test02 I get the traceback
 
 Traceback (innermost last):
   File string, line 1, in ?
   File D:\PythonCode\pna\eyeTracking\tests\test02.py, line 15, in ?
 x0 = wrappers_A01.ImStream_SavedBitmaps()
   File D:\PythonCode\pna\eyeTracking\tests\wrappers_A01.py, line 21,
 in __init__
 cbase.CImStream.__init__(self)
 TypeError: unbound method must be called with class instance 1st
 argument
 
 
 Any ideas what I am doing wrong?
 
 Thanks,
 Marc

Yes my post has a mistake re: polymorphism. It seems self.__class__, whether 
called directly or indirectly, is always going to refer to the parent of the 
instance class. My code works only if there are no grandparents.


Bummer, but glad to learn something new.

It's too bad, I really lean on reload(). It appears to be incompatible with 
inheritance more than one level deep.

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


Re: What minimum should a person know before saying I know Python

2013-09-20 Thread Chris Angelico
On Sat, Sep 21, 2013 at 3:40 AM, Aseem Bansal asmbans...@gmail.com wrote:
 On Friday, September 20, 2013 10:04:32 PM UTC+5:30, Chris Angelico wrote:
 On Sat, Sep 21, 2013 at 2:28 AM, Aseem Bansal asmbans...@gmail.com wrote:
  I hope that cleared some confusion about what I wanted to ask. I wanted to 
  gauge myself to find if I am progressing or not.

 Well, based on my definition, that's easy to answer. Have you solved
 problems using Python? If you have a bunch of HTML pages and you need
 to get some info out of all of them by COB today, do you think I can
 do that with Python, or do you think I can do that with sed, awk,
 grep, and five levels of pipe? The tools you use for an urgent job
 will be the ones you know.

 ChrisA

 Yeah I have...
 But that was pure luck that I had done the random example that you had 
 chosen. It would be difficult to find my overall progress by the one thing.

 I am currently unemployed so the sense of urgency isn't there normally. 
 That's why I asked this question. But I got your point.

It wasn't exactly a random example; it's an extremely common task
(maybe without the must be done today restriction), and one that
Python happens to do fairly well. :)

There was a time, back in the 1990s, when REXX was my primary
language. (We were exclusively an OS/2 shop at the time, so it was a
good choice.) If I needed to write a quick script, it would be in
REXX. If I needed to parse text, I'd use REXX. If I wanted a GUI app,
I'd write it in VX-REXX. Later on, when I needed to write Windows
code, I tended to use C++. It wasn't till the late 2000s that I
started using Python for those sorts of jobs - even though I'd met the
language back in the 90s - indicating that that's when I actually knew
the language.

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


Re: What minimum should a person know before saying I know Python

2013-09-20 Thread Roy Smith
In article mailman.192.1379694881.18130.python-l...@python.org,
 Chris Angelico ros...@gmail.com wrote:

 On Sat, Sep 21, 2013 at 2:28 AM, Aseem Bansal asmbans...@gmail.com wrote:
  I hope that cleared some confusion about what I wanted to ask. I wanted to 
  gauge myself to find if I am progressing or not.
 
 Well, based on my definition, that's easy to answer. Have you solved
 problems using Python? If you have a bunch of HTML pages and you need
 to get some info out of all of them by COB today, do you think I can
 do that with Python, or do you think I can do that with sed, awk,
 grep, and five levels of pipe? The tools you use for an urgent job
 will be the ones you know.

The fact that you reach for traditional command-line tools to parse HTML 
should not be taken as evidence that you don't know Python.  It should 
be taken as evidence that you have a lot of tools in your quiver and 
know when to use the right one.

I started with Python in the 1.4 days.  I will reach for Python these 
days in preference to Perl, Tcl, C, C++, Java, or PHP for most things.  
But, for a lot of basic text processing, I can throw together a sed, 
awk, grep, sort, uniq, wc, tac, tail, etc pipeline faster than I can 
write a Python program to do the same thing.

Oh, and by the way, the python.org home page has

$ curl -s python.org | tr ' ' '\n' | grep ^href= | wc -l
 124

124 links on it.

You're still reading the BeautifulSoup docs :-)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Print statement not printing as it suppose to

2013-09-20 Thread Chris Angelico
On Sat, Sep 21, 2013 at 7:57 AM, Sam anasdah...@gmail.com wrote:
 car=int(input(Lamborghini tune-up:))
 print(\nThe total amount required is , total )
 OUTPUT
 ('\nThe total amount required is ', 3534)

As others have said, this output indicates that you're running under a
Python 2.x interpreter. I strongly recommend you switch to running
under Python 3.x - do not take the simple advice that might make it
work in both, because you have other differences which will trip you
up. In Python 2, the input function is extremely dangerous and should
be avoided: it *evaluates* its argument. (If you really *want* to
evaluate something, you can call the eval() function explicitly. You
don't want it to be hidden behind the innocuously-named input().)
Download Python 3.3 (or later) and start using that; you'll find it's
by far the better interpreter - years of improvements on top of the
version you're using there.

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


Re: What minimum should a person know before saying I know Python

2013-09-20 Thread Chris Angelico
On Sat, Sep 21, 2013 at 12:31 PM, Roy Smith r...@panix.com wrote:
 In article mailman.192.1379694881.18130.python-l...@python.org,
  Chris Angelico ros...@gmail.com wrote:

 On Sat, Sep 21, 2013 at 2:28 AM, Aseem Bansal asmbans...@gmail.com wrote:
  I hope that cleared some confusion about what I wanted to ask. I wanted to
  gauge myself to find if I am progressing or not.

 Well, based on my definition, that's easy to answer. Have you solved
 problems using Python? If you have a bunch of HTML pages and you need
 to get some info out of all of them by COB today, do you think I can
 do that with Python, or do you think I can do that with sed, awk,
 grep, and five levels of pipe? The tools you use for an urgent job
 will be the ones you know.

 The fact that you reach for traditional command-line tools to parse HTML
 should not be taken as evidence that you don't know Python.  It should
 be taken as evidence that you have a lot of tools in your quiver and
 know when to use the right one.

 I started with Python in the 1.4 days.  I will reach for Python these
 days in preference to Perl, Tcl, C, C++, Java, or PHP for most things.
 But, for a lot of basic text processing, I can throw together a sed,
 awk, grep, sort, uniq, wc, tac, tail, etc pipeline faster than I can
 write a Python program to do the same thing.

Oh, absolutely! I never said that sed/awk/grep was a bad way to do
things; my point is that, when there are dozens of viable solutions to
a problem and you have to solve that problem *now*, you are going to
reach for the one you know best. I use sed all the time (it's one of
the easiest ways to edit a root-owned file from a non-root shell
script - 'sudo sed -i').

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


Re: mutlifile inheritance problem

2013-09-20 Thread Chris Angelico
On Sat, Sep 21, 2013 at 10:17 AM, Peter Cacioppi
peter.cacio...@gmail.com wrote:
 It's too bad, I really lean on reload(). It appears to be incompatible with 
 inheritance more than one level deep.

Python's really not designed for reload of this nature. You can easily
make a nasty mess of things. If you're working in the interactive
interpreter, it's probably easier to just run a stand-alone program
and restart it every time; if you're actually trying to have an
application that runs long-term and can reload code on the fly, you
may want to consider a language that explicitly supports that (such as
Pike).

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


Re: pyGTK Help Needed Please

2013-09-20 Thread Michael Torrie
On 09/20/2013 12:30 PM, bingefel...@gmail.com wrote:
 Hi folks,
 
 I'm trying to run a program called Nicotine+ on my Mac which is running 
 10.8.5. Nicotine+ requires GTK2, pyGTK2 and Python to run. I believe I have 
 all of these installed via Macports (please see here - 
 http://pastebin.com/nwmrpp2Y )
 
 When I try to run Nicotine+ I get this message:
 
 '/Users/**/Downloads/nicotine+-1.2.16', 
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', 
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', 
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
  
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
  
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
  
 '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', 
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
  
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
  
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
  
 '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC',
  '/Library/Python/2.7/site-packages']
 Exception: No module named pygtk
 
 
 If I run Python and type import pygtk I get this message:
 
 Traceback (most recent call last):
 File stdin, line 1, in module
 ImportError: No module named pygtk
 
 
 can anyone help me please?

You probably need to run the program using the version of Python that's
installed in MacPorts.  Your system python does not know anything about
MacPorts, so it obviously can't find pyGTK, since it's not in the system
library location.  I can't remember where MacPorts puts things, but
presumably you'd have to do edit the nicotine+-1.2.16 file and change
the first line to point to the MacPorts version of python.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Print statement not printing as it suppose to

2013-09-20 Thread Dave Angel
On 20/9/2013 17:57, Sam wrote:


 print(\nThe total amount required is , total )


 ('\nThe total amount required is ', 3534)

 === the problem is obviously on the last print statement that is supposed to 
 print the outut

Others have pointed out the version discrepancy.  But I'll also ask what
you're learning Python from.  If you've got a tutorial or book that uses
Python 3.x, then forget 2.x and install 3.3

If you're learning it in a class, then the instructor should already
have told you what version to use.

It is possible to install both 2.7 and 3.3, but you probably don't need
the confusion while you're learning.

-- 
DaveA


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


[issue19048] itertools.tee doesn't have a __sizeof__ method

2013-09-20 Thread Martin v . Löwis

Martin v. Löwis added the comment:

Antoine: in (my experience of) memory analysis, the size of a single object is 
mostly irrelevant. If you need to know how much memory something consumes, you 
typically want to know the memory of a set of objects. So this is the case that 
really must be supported.

For that, users will have to use libraries that know how to count memory. It's 
not asked to much that the authors of such libraries know about internals of 
Python (such as the existence of sys.getsizeof, or gc.get_referents). The 
question is: can such a library reasonably implemented? For that, it is 
important that getsizeof behaves uniformly across objects.

If you really don't like the proposed uniformity, please propose a different 
rule. However, don't give deviations in other places (OrderedDict) as a reason 
to break the rule here as well. Instead, if OrderedDict.__getsizeof__ is 
broken, it needs to be fixed as well.

--

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



[issue18990] Return root element from ElementTree.XMLPullParser.close() to match ElementTree.XMLParser

2013-09-20 Thread Nick Coghlan

Nick Coghlan added the comment:

It's the docs for XMLPullParser.close that need to be updated.

On 20 September 2013 15:59, Stefan Behnel rep...@bugs.python.org wrote:

 Stefan Behnel added the comment:

 I'm not entirely happy about the docs anyway. Most people just want to loop 
 over iterparse() and be done (use case being to save memory). The new parser 
 class is a rather special and more complex thing that we shouldn't let 
 innocent users run into that easily. But that's a different ticket, I guess, 
 and in no way time critical.

 I can't see a reference to parser.root in the ElementTree doc page, BTW, so 
 maybe there's just nothing to do there?

 --

 ___
 Python tracker rep...@bugs.python.org
 http://bugs.python.org/issue18990
 ___

--

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



[issue18990] Return root element from ElementTree.XMLPullParser.close() to match ElementTree.XMLParser

2013-09-20 Thread Stefan Behnel

Stefan Behnel added the comment:

Ah, right - I forgot that it currently only implements a part of the parser API 
in ElementTree. Adding Returns the toplevel document element. behind the 
current sentence would do, I guess. That will need updating once the 
XMLPullParser implements support for parser targets, though. Also, the 
description could just be dropped if XMLPullParser inherited from XMLParser 
(ticket #19010), because it's just (or should just be) a redundant repitition. 
All that's really new is the read_events() method and the constructor's 
arguments. Keeping the rest out would simplify both the interface and the 
documentation.

--

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



[issue19044] getaddrinfo raises near-useless exception

2013-09-20 Thread Balazs

Balazs added the comment:

Hi, this is the platform:

Linux cloudbackupbr 3.8.0-30-generic #44-Ubuntu SMP Thu Aug 22 20:52:24 UTC 
2013 x86_64 x86_64 x86_64 GNU/Linux

/bin/bash: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically 
linked (uses shared libs), for GNU/Linux 2.6.24, 
BuildID[sha1]=0x6db033ec6858b391e114e252b3354ddbf5a9f7be, stripped

Thanks

--

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



[issue11632] difflib.unified_diff loses context

2013-09-20 Thread Benoît D Vages

Benoît D Vages added the comment:

An other exemple if necessary (python 2.6 / 2.7)
Got same behavior than mal using his script and my files.

Seems to occur when the chunk of lines between 2 differences is repeated many 
times in the file

--
nosy: +folder4ben
Added file: http://bugs.python.org/file31823/450.zip

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



[issue19049] itertools.tee uses int for indices

2013-09-20 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

There are disadvantages in the changing int to Py_ssize_t. Converting 
Py_ssize_t  to/from Python int is a little harder than converting C int or 
long. This change (as any other change) has a risk of introduce new bugs (as 
you can see on example of your patch).

I suggest just add (yet one) explicit comment.

int index; /* 0 = index = LINKCELLS */

--

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



[issue19056] Windows 7, script exec not working without explicit cal of python.exe

2013-09-20 Thread Thierry Seunevel

New submission from Thierry Seunevel:

Executing a script from the command prompt works if Python.exe called 
explicitly, doesn't work if script name only.
Example :
python.exe script.py is ok
script.py gives the following :
Traceback (most recent call last):
  File D:\soft\python\lib\site.py, line 548, in module
main()
  File D:\soft\python\lib\site.py, line 530, in main
known_paths = addusersitepackages(known_paths)
  File D:\soft\python\lib\site.py, line 266, in addusersitepackages
user_site = getusersitepackages()
  File D:\soft\python\lib\site.py, line 241, in getusersitepackages
user_base = getuserbase() # this will also set USER_BASE
  File D:\soft\python\lib\site.py, line 231, in getuserbase
USER_BASE = get_config_var('userbase')
  File D:\soft\python\lib\sysconfig.py, line 516, in get_config_var
return get_config_vars().get(name)
  File D:\soft\python\lib\sysconfig.py, line 449, in get_config_vars
import re
  File D:\soft\python\lib\re.py, line 105, in module
import sre_compile
  File D:\soft\python\lib\sre_compile.py, line 14, in module
import sre_parse
  File D:\soft\python\lib\sre_parse.py, line 17, in module
from sre_constants import *
  File D:\soft\python\lib\sre_constants.py, line 18, in module
from _sre import MAXREPEAT
ImportError: cannot import name MAXREPEAT
Association of py extension to the python.exe is ok, Path contains the path for 
python directory (and also to \lib) and is the first dir in path.
Why is there a difference between the 2 invocations as they are calling the 
same exe?

--
components: Windows
messages: 198136
nosy: tsunwell
priority: normal
severity: normal
status: open
title: Windows 7, script exec not working without explicit cal of python.exe
type: behavior
versions: Python 2.7

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



[issue19049] itertools.tee uses int for indices

2013-09-20 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 I suggest just add (yet one) explicit comment.
 
 int index; /* 0 = index = LINKCELLS */

Ok, I think a comment is good enough here.

--

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



[issue19045] Make on Solaris 11 x64 with OracleStudio12.3 failed

2013-09-20 Thread Borut Podlipnik

Borut Podlipnik added the comment:

Using c compiler instead of c++ compiler, solved the problem:
setenv CC cc 
setenv CXX cc 
setenv LD_LIBRARY_PATH /opt/solarisstudio12.3/lib:/usr/lib

# ./configure --without-gcc --with-cxx-main=CC --prefix=/opt/python
# make
# make test

However, make test failed:
….
352 tests OK.
3 tests failed:
test_ctypes test_posix test_uuid
1 test altered the execution environment:
test_distutils
36 tests skipped:
test_aepack test_al test_applesingle test_bsddb185 test_bsddb3
test_cd test_cl test_codecmaps_cn test_codecmaps_hk
test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_curses
test_epoll test_gdb test_gl test_imgfile test_kqueue
test_linuxaudiodev test_macos test_macostools test_msilib
test_ossaudiodev test_scriptpackages test_smtpnet
test_socketserver test_startfile test_sunaudiodev test_timeout
test_tk test_ttk_guionly test_urllib2net test_urllibnet
test_winreg test_winsound test_zipfile64
4 skips unexpected on sunos5:
test_gdb test_sunaudiodev test_tk test_ttk_guionly
*** Error code 1
make: Fatal error: Command failed for target `test'
# 

# ./python Lib/test/regrtest.py -v test_uuid
== CPython 2.7.5 (default, Sep 19 2013, 12:00:58) [C]
==   Solaris-2.11-i86pc-i386-32bit-ELF little-endian
==   /home/borut/admin/python/Python-2.7.5/build/test_python_14443
Testing with flags: sys.flags(debug=0, py3k_warning=0, division_warning=0, 
division_new=0, inspect=0, interactive=0, optimize=0, dont_write_bytecode=0, 
no_user_site=0, no_site=0, ignore_environment=0, tabcheck=0, verbose=0, 
unicode=0, bytes_warning=0, hash_randomization=0)
test_uuid
testIssue8621 (test.test_uuid.TestUUID) ... ok
test_UUID (test.test_uuid.TestUUID) ... ok
test_exceptions (test.test_uuid.TestUUID) ... ok
test_getnode (test.test_uuid.TestUUID) ... ok
test_ifconfig_getnode (test.test_uuid.TestUUID) ... ok
test_ipconfig_getnode (test.test_uuid.TestUUID) ... ok
test_netbios_getnode (test.test_uuid.TestUUID) ... ok
test_random_getnode (test.test_uuid.TestUUID) ... ok
test_unixdll_getnode (test.test_uuid.TestUUID) ... ok
test_uuid1 (test.test_uuid.TestUUID) ... ok
test_uuid3 (test.test_uuid.TestUUID) ... ok
test_uuid4 (test.test_uuid.TestUUID) ... FAIL
test_uuid5 (test.test_uuid.TestUUID) ... ok
test_windll_getnode (test.test_uuid.TestUUID) ... ok

==
FAIL: test_uuid4 (test.test_uuid.TestUUID)
--
Traceback (most recent call last):
  File /home/borut/admin/python/Python-2.7.5/Lib/test/test_uuid.py, line 422, 
in test_uuid4
equal(u.variant, uuid.RFC_4122)
AssertionError: 'reserved for future definition' != 'specified in RFC 4122'

--
Ran 14 tests in 0.166s

FAILED (failures=1)
test test_uuid failed -- Traceback (most recent call last):
  File /home/borut/admin/python/Python-2.7.5/Lib/test/test_uuid.py, line 422, 
in test_uuid4
equal(u.variant, uuid.RFC_4122)
AssertionError: 'reserved for future definition' != 'specified in RFC 4122'

1 test failed:
test_uuid
# 

# ./python Lib/test/regrtest.py -v test_ctypes
== CPython 2.7.5 (default, Sep 19 2013, 12:00:58) [C]
==   Solaris-2.11-i86pc-i386-32bit-ELF little-endian
==   /home/borut/admin/python/Python-2.7.5/build/test_python_14454
Testing with flags: sys.flags(debug=0, py3k_warning=0, division_warning=0, 
division_new=0, inspect=0, interactive=0, optimize=0, dont_write_bytecode=0, 
no_user_site=0, no_site=0, ignore_environment=0, tabcheck=0, verbose=0, 
unicode=0, bytes_warning=0, hash_randomization=0)
test_ctypes
test_incomplete_example (ctypes.test.test_incomplete.MyTestCase) ... ok
test_native (ctypes.test.test_unaligned_structures.TestStructures) ... ok
test_swapped (ctypes.test.test_unaligned_structures.TestStructures) ... ok


==
FAIL: test_ints (ctypes.test.test_bitfields.C_Test)
--
Traceback (most recent call last):
  File 
/home/borut/admin/python/Python-2.7.5/Lib/ctypes/test/test_bitfields.py, line 
40, in test_ints
self.assertEqual((name, i, getattr(b, name)), (name, i, func(byref(b), 
name)))
AssertionError: Tuples differ: ('A', 1, -1) != ('A', 1, 1)

First differing element 2:
-1
1

- ('A', 1, -1)
?  -

+ ('A', 1, 1)

==
FAIL: test_shorts (ctypes.test.test_bitfields.C_Test)
--
Traceback (most recent call last):
  File 
/home/borut/admin/python/Python-2.7.5/Lib/ctypes/test/test_bitfields.py, line 
47, in test_shorts
self.assertEqual((name, i, getattr(b, name)), (name, i, func(byref(b), 
name)))
AssertionError: Tuples differ: ('R', 32, -32) != ('R', 32, 32)

First differing element 2:
-32
32

- ('R', 

[issue11220] Sometimes library raises URLError when trying POST with httpS

2013-09-20 Thread mrDoctorWho0 .

mrDoctorWho0 . added the comment:

Trying to use POST-request to https://vk.com and sometimes library raise an 
error.
  File library/vkApi.py, line 31, in post
response = self.Opener.open(request)
  File /usr/lib/python2.7/urllib2.py, line 404, in open
response = self._open(req, data)
  File /usr/lib/python2.7/urllib2.py, line 422, in _open
'_open', req)
  File /usr/lib/python2.7/urllib2.py, line 382, in _call_chain
result = func(*args)
  File /usr/lib/python2.7/urllib2.py, line 1222, in https_open
return self.do_open(httplib.HTTPSConnection, req)
  File /usr/lib/python2.7/urllib2.py, line 1184, in do_open
raise URLError(err)
URLError: urlopen error _ssl.c:489: The handshake operation timed out

--
components: +Library (Lib) -None
nosy: +mrDoctorWho0..
title: https sslv3 error 14077417: illegal parameter - Sometimes library 
raises URLError when trying POST with httpS
versions: +Python 2.7 -Python 2.6, Python 3.1
Added file: http://bugs.python.org/file31824/code.py

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



[issue11220] Sometimes library raises URLError when trying POST with httpS

2013-09-20 Thread mrDoctorWho0 .

mrDoctorWho0 . added the comment:

oops! wrong place!

--

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



[issue11220] Sometimes library raises URLError when trying POST with httpS

2013-09-20 Thread mrDoctorWho0 .

Changes by mrDoctorWho0 . mrdoctor...@gmail.com:


Removed file: http://bugs.python.org/file31824/code.py

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



[issue19057] Sometimes urllib2 raises URLError when trying POST with httpS

2013-09-20 Thread mrDoctorWho0 .

New submission from mrDoctorWho0 .:

Trying to use POST-request to https://vk.com and sometimes library raise an 
error.
  File library/vkApi.py, line 31, in post
response = self.Opener.open(request)
  File /usr/lib/python2.7/urllib2.py, line 404, in open
response = self._open(req, data)
  File /usr/lib/python2.7/urllib2.py, line 422, in _open
'_open', req)
  File /usr/lib/python2.7/urllib2.py, line 382, in _call_chain
result = func(*args)
  File /usr/lib/python2.7/urllib2.py, line 1222, in https_open
return self.do_open(httplib.HTTPSConnection, req)
  File /usr/lib/python2.7/urllib2.py, line 1184, in do_open
raise URLError(err)
URLError: urlopen error _ssl.c:489: The handshake operation timed out

This exception appears randomly, connection is ok 100%. I tried it on different 
machines with python 2.7.4 and 2.7.3.

--
components: Library (Lib)
files: code.py
messages: 198141
nosy: mrDoctorWho0..
priority: normal
severity: normal
status: open
title: Sometimes urllib2 raises URLError when trying POST with httpS
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file31825/code.py

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



[issue6792] Distutils-based installer does not detect 64bit versions of Python

2013-09-20 Thread Christopher Benson

Changes by Christopher Benson chris.benson...@gmail.com:


--
nosy: +ChrisBenson

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



[issue11220] https sslv3 error 14077417: illegal parameter

2013-09-20 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com:


--
nosy:  -mrDoctorWho0..
title: Sometimes library raises URLError when trying POST with httpS - https 
sslv3 error 14077417: illegal parameter
versions: +Python 2.6, Python 3.1 -Python 2.7

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



[issue11220] https sslv3 error 14077417: illegal parameter

2013-09-20 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com:


--
Removed message: http://bugs.python.org/msg198139

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



[issue11220] https sslv3 error 14077417: illegal parameter

2013-09-20 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com:


--
Removed message: http://bugs.python.org/msg198140

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



[issue19009] Enhance HTTPResponse.readline() performance

2013-09-20 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

After adding read1() and peek() what stop us from inheriting HTTPResponse from 
BufferedIOBase?

I suggest split _read1_or_peek_chunked() by two parts. First part calculates n 
bounded by chunk_left (it can read the next chunk size and close a connection 
if needed). Perhaps it can be reused in _readall_chunked() and 
_readinto_chunked(() too. Second part which is  controlled by boolean parameter 
should be moved out in read1() and peek().

--

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



[issue19051] Unify buffered readers

2013-09-20 Thread Antoine Pitrou

Antoine Pitrou added the comment:

If you want this, I think it should be somehow folded into existing classes 
(for example BufferedIOBase). Yet another implementation of readline() isn't 
really a good idea.

--

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



[issue18756] os.urandom() fails under high load

2013-09-20 Thread Adam Bielański

Changes by Adam Bielański abg...@gmail.com:


--
nosy: +Adam.Bielański

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



[issue18003] lzma module very slow with line-oriented reading.

2013-09-20 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

See issue19051. Even preliminary Python implementation noticeable speed up the 
reading of short lines.

$ ./python -m timeit -s import lzma, io f=lzma.LZMAFile('words.xz', 'r') 
for line in f: pass

Unpatched: 1.44 sec per loop
Patched: 1.06 sec per loop

With C implementation it should be as fast as with BufferedReader.

--

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



[issue18990] Return root element from ElementTree.XMLPullParser.close() to match ElementTree.XMLParser

2013-09-20 Thread Eli Bendersky

Eli Bendersky added the comment:

Hi Nick,

I disagree with this change. The way the APIs are currently defined, XMLParser 
and XMLPullParser are different animals. XMLParser can be considered to only 
have one front in the API - feed() and close(). You feed() until the document 
is done and then you close() and get the parsed tree. There's no other way to 
get the parsed tree (unless you use a custom builder, I guess).

On the other hand XMLPullParser has two clear fronts - an input front with 
feed() and close() and an output front with read_events(). For XMLPullParser, 
close() is just an input signal. The canonical way to get output from 
XMLPullParser is read_events(). close() has no better reason to return output 
than feed(). When we decided to change the method names (recall that Antoine's 
originals were completely different), we perhaps forgot this detail. Even 
though XMLPullParser's method is named close(), it's *not* like XMLParser's 
close(). If someone is using XMLPullParser for its close() he's likely using 
the class incorrectly.

Just as an example: consider that in a lot of use cases the programmer will 
want to discard parts of the tree that's parsed iteratively (similarly to the 
main use case of iterparse()), because the XML itself is too huge. It's a 
convenient streaming API, in other words. Now, if the reader discards parts of 
the tree (by deleting subtrees), then returning the root from close() becomes 
even more meaningless, because it's no longer the root and we have no idea what 
it actually is.

Finally, I will add that we can always err on the side of under-specifying. We 
plan to change the implementation of the class in the future, so we can always 
add to the API. Specifying that close() returns the root is something we can't 
back out of, but we can always add in a future release without hurting 
backwards compatibility, if we do reach the conclusion that it's better.

---

P.S. all of this makes me wonder if we should mark the API of XMLPullParser 
provisional for 3.4

--

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



[issue18003] lzma module very slow with line-oriented reading.

2013-09-20 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 With C implementation it should be as fast as with BufferedReader.

So why not simply use BufferedReader?

--

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



[issue19057] Sometimes urllib2 raises URLError when trying POST with httpS

2013-09-20 Thread R. David Murray

R. David Murray added the comment:

I would guess that if you did a network trace you'd find out there really was a 
packet that did not arrive (a timeout).  Note that detecting this is 
complicated by the fact that ssl is involved.  (I don't know the details, but I 
remember someone saying that more than one packet may be involved in something 
that looks like a single event at the OpenSSL level.)

It is certainly *possible* that there is a bug at the OpenSSL or (less likely) 
the _ssl module level, but the first step in debugging it would be to get that 
network trace, I think...

As I said, though, I'm not an expert in this area, perhaps someone who is will 
have other suggestions.

--
nosy: +r.david.murray

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



[issue19009] Enhance HTTPResponse.readline() performance

2013-09-20 Thread Kristján Valur Jónsson

Kristján Valur Jónsson added the comment:

Ok, I have refactored this a bit.
A separate new function now takes care of the reading of chunk-header and tail. 
 This simplifies the other functions.

I'm not sure what you mean by inheriting from the buffered class.  Do we gain 
anything by doing that, would it change the code? or would it merely be for the 
benefit of ABC?

Note that the chunk protocol was wrong and I fixed the unittests:  The final 
chunk is a _valid_ zero length chunk, i.e. 0\r\n\r\n.  It contains two eol 
tokens like other chunks, one at the end of the length, the other at the end of 
the(null) payload.

--
Added file: http://bugs.python.org/file31826/httpresponse.patch

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



  1   2   >