Re: Command Line Inputs from Windows

2015-01-03 Thread Mark Lawrence

On 02/01/2015 19:44, Ken Stewart wrote:

Court of King Arthur,


Court of BDFL actually.



I’d appreciate any help you can provide.  I’m having problems passing
command line parameters from Windows 7 into a Python script (using
Python 3.4.2).  It works correctly when I call the interpreter
explicitly from the Windows command prompt, but it doesn’t work when I
enter the script name without calling the Python interpreter.

This works:
python myScript.py arg1 arg2 arg3

This doesn’t work:
myScript.py arg1 arg2 arg3

The Windows PATH environment variable contains the path to Python, as
well as the path to the Script directory.  The PATHEXT environment
variable contains the Python extension (.py).

There are other anomalies too between the two methods of invoking the
script depending on whether I include the extension (.py) along with the
script name.  For now I’m only interested in passing the arguments
without explicitly calling the Python interpreter.


Here is the script:

#! python

import sys

def getargs():
sys.stdout.write("\nHello from Python %s\n\n" % (sys.version,))
print ('Number of arguments =', len(sys.argv))
print ('Argument List =', str(sys.argv))

if __name__ == '__main__':
getargs()


Result_1 (working correctly):

C:\Python34\Scripts> python myScript.py arg1 arg2 arg3

Hello from Python 3.4.2 (v3.4.2:ab2c023a9432, Oct  6 2014, 22:15:05)
[MSC v.1600 32 bit (Intel)]

Number of arguments = 4
Argument List = ['myScript.py', 'arg1', 'arg2', 'arg3']


Result_ 2 (Fail)

C:\Python34\Scripts> myScript.py arg1 arg2 arg3

Hello from Python 3.4.2 (v3.4.2:ab2c023a9432, Oct  6 2014, 22:15:05)
[MSC v.1600 32 bit (Intel)]

Number of arguments = 1
Argument List = ['C:\\Python34\\Scripts\\myScript.py']

As a beginner I’m probably making a mistake somewhere but I can’t find
it. I don’t think the shebang does anything in Windows but I’ve tried
several variations without success.  I’ve tried writing the script using
only commands, without the accouterments of a full program (without the
def statement and without the if __name__ == ‘__main__’ …) to no avail.
I’m out of ideas.  Any suggestions?

Ken Stewart



Works fine for me with this:-

c:\Users\Mark\Documents\MyPython>assoc .py
.py=Python.File

c:\Users\Mark\Documents\MyPython>assoc .pyw
.pyw=Python.NoConFile

c:\Users\Mark\Documents\MyPython>ftype Python.File
Python.File="C:\Windows\py.exe" "%1" %*

c:\Users\Mark\Documents\MyPython>ftype Python.NoConFile
Python.NoConFile="C:\Windows\pyw.exe" "%1" %*

c:\Users\Mark\Documents\MyPython>set pathext
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY

This is set up by the Python Launcher for Windows, introduced in 3.3, 
see https://docs.python.org/3/using/windows.html#launcher, noting that 
shebang lines also work.


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

Mark Lawrence

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


Re: Command Line Inputs from Windows

2015-01-03 Thread Ken Stewart

Chris, Dennis, James, and Mark:

SUCCESS!  Thanks for your suggestions.  It was the registry.  Kudos to 
Dennis.  The data strings for a lot of different "command" keys in the 
registry were missing the %* (percent star) characters.  Thanks Chris for 
the explanation on why the %* string is needed.


Here is a sample key:
S1-5-21-1560217580-722697556-320042093-1000-Classes
   py_auto_file
   shell
   open
   command

The corrected data for the key looks like this:

"C:\Python34\python.exe" %1 %*

I used the 'find' tool in regedit to search for python in the registry. 
There were many hits on the word python but only a handful had data fields 
similar to the one above.  Every instance was missing the %* string.  I 
modified them all.  My script didn't start working until after I'd modified 
the very last one.  Happily, my computer still boots after mucking around in 
the registry.


I haven't yet investigated the launcher suggested by Chris and Mark.  That 
may well be the proper solution.  At the moment it looks like the Python 
installer didn't create these registry entries properly in Windows 7.


Thanks again

Ken Stewart

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


Re: Command Line Inputs from Windows

2015-01-03 Thread Chris Angelico
On Sat, Jan 3, 2015 at 7:03 PM, Ken Stewart  wrote:
> I used the 'find' tool in regedit to search for python in the registry.
> There were many hits on the word python but only a handful had data fields
> similar to the one above.  Every instance was missing the %* string.  I
> modified them all.  My script didn't start working until after I'd modified
> the very last one.  Happily, my computer still boots after mucking around in
> the registry.

Excellent!

Fiddling with Python's setup under Windows is unlikely ever to stop
your computer from booting. Unlike on most Linux and Mac OS systems,
there's no "system Python" that's used internally; Windows itself
doesn't make use of Python. So you should have no problems playing
around with things.

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


Re: Command Line Inputs from Windows

2015-01-03 Thread Mark Lawrence

On 03/01/2015 08:03, Ken Stewart wrote:

At the moment it looks like the
Python installer didn't create these registry entries properly in
Windows 7.



If that is actally the case please raise an issue on the bug tracker at 
bugs.python.org if one doesn't already exist.


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

Mark Lawrence

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


Re: How do I remove/unlink wildcarded files

2015-01-03 Thread Steven D'Aprano
Chris Angelico wrote:

> On Sat, Jan 3, 2015 at 4:54 AM, Rustom Mody  wrote:
>> And how does this strange language called English fits into your rules
>> and (no) special cases scheme?
>>
>>
http://www.omgfacts.com/lists/3989/Did-you-know-that-ough-can-be-pronounced-TEN-DIFFERENT-WAYS
> 
> I learned six, which is no more than there are for the simple vowel
> 'a' (at least, in British English; American English has a few less
> sounds for 'a'). 

What is this thing you call "American English"? :-) 

I wouldn't want to put an exact number of distinct accents in the USA, but
it's probably in three figures. And it used to be said that a sufficiently
skilled linguist could tell what side of the street an English person was
born on, that's how fine-grained English accents used to be.


> Consider "cat", "bay", "car" (that's the three most 
> common sounds), "watch", "water", "parent" (these three are less
> common, and American English often folds them into the other three).

There's a joke about how people from certain parts of the US suffer
from "hat attacks" (heart attacks).


> Now have a look at Norwegian, where the fifth of those sounds
> ("water") is spelled with a ring above, eg "La den gå" - and the sixth
> is (I think) more often spelled with a slashed O - "Den kraften jeg
> skjulte før". Similarly in Swedish: "Slå dig loss, slå dig fri" is
> pronounced "Slaw di loss, slaw di free". Or let's look at another of
> English's oddities. Put a t and an h together, and you get a
> completely different sound... two different sounds, in fact, voiced or
> unvoiced. Icelandic uses thorn instead: "Þetta er nóg" is pronounced
> (roughly) "Thetta air know".

English used to include the letter Thorn too. Among others. Little known
fact: at one time, ampersand & (as in "and") used to be included as a
letter of the alphabet

http://mentalfloss.com/article/31904/12-letters-didnt-make-alphabet


> And the whole notion of putting a dot on 
> a lower-case i and not putting one on upper-case I is pretty
> illogical, but Turkish, as I mentioned in the previous post, uses the
> dots to distinguish between two pronunciations of the vowel, hence
> "aldırma" which would sound somewhat different with a dot on the i.
> 
> (You may be able to see a theme in my example texts, but I figured
> it's time to see what I can do with full Unicode support. The cold
> looks of disapproval never bothered me, anyway.)
> 
> ChrisA

-- 
Steven

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


Re: How do I remove/unlink wildcarded files

2015-01-03 Thread Chris Angelico
On Sat, Jan 3, 2015 at 9:01 PM, Steven D'Aprano
 wrote:
> Chris Angelico wrote:
>
>> On Sat, Jan 3, 2015 at 4:54 AM, Rustom Mody  wrote:
>>> And how does this strange language called English fits into your rules
>>> and (no) special cases scheme?
>>>
>>>
> http://www.omgfacts.com/lists/3989/Did-you-know-that-ough-can-be-pronounced-TEN-DIFFERENT-WAYS
>>
>> I learned six, which is no more than there are for the simple vowel
>> 'a' (at least, in British English; American English has a few less
>> sounds for 'a').
>
> What is this thing you call "American English"? :-)
>
> I wouldn't want to put an exact number of distinct accents in the USA, but
> it's probably in three figures. And it used to be said that a sufficiently
> skilled linguist could tell what side of the street an English person was
> born on, that's how fine-grained English accents used to be.

"American English" is the category compassing all of those accents
common to the USA. There are certain broad similarities between it and
British English, just as there are similarities between Dutch and
German; and there are certain commonalities across all accents of
American English, allowing generalizations about the number of sounds
made by the vowel "a". :)

>> Now have a look at Norwegian, where the fifth of those sounds
>> ("water") is spelled with a ring above, eg "La den gå" - and the sixth
>> is (I think) more often spelled with a slashed O - "Den kraften jeg
>> skjulte før". Similarly in Swedish: "Slå dig loss, slå dig fri" is
>> pronounced "Slaw di loss, slaw di free". Or let's look at another of
>> English's oddities. Put a t and an h together, and you get a
>> completely different sound... two different sounds, in fact, voiced or
>> unvoiced. Icelandic uses thorn instead: "Þetta er nóg" is pronounced
>> (roughly) "Thetta air know".
>
> English used to include the letter Thorn too. Among others.

Yes, but it doesn't any more. Icelandic is the only modern language
I'm aware of that retains thorn and eth (eg in "það").

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


Re: How do I remove/unlink wildcarded files

2015-01-03 Thread Mark Lawrence

On 03/01/2015 10:16, Chris Angelico wrote:

On Sat, Jan 3, 2015 at 9:01 PM, Steven D'Aprano
 wrote:

Chris Angelico wrote:


On Sat, Jan 3, 2015 at 4:54 AM, Rustom Mody  wrote:

And how does this strange language called English fits into your rules
and (no) special cases scheme?



http://www.omgfacts.com/lists/3989/Did-you-know-that-ough-can-be-pronounced-TEN-DIFFERENT-WAYS


I learned six, which is no more than there are for the simple vowel
'a' (at least, in British English; American English has a few less
sounds for 'a').


What is this thing you call "American English"? :-)

I wouldn't want to put an exact number of distinct accents in the USA, but
it's probably in three figures. And it used to be said that a sufficiently
skilled linguist could tell what side of the street an English person was
born on, that's how fine-grained English accents used to be.


"American English" is the category compassing all of those accents
common to the USA. There are certain broad similarities between it and
British English, just as there are similarities between Dutch and
German; and there are certain commonalities across all accents of
American English, allowing generalizations about the number of sounds
made by the vowel "a". :)



I used to get very confused watching the old westerns.  The child when 
talking about "more" and "paw" wasn't referring to possibly an 
adjective, noun or adverb and a part of an animal, but what we would 
refer to in the UK as "mum" and "dad" :)


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

Mark Lawrence

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


DjangoCon Europe 2015, in Cardiff, Wales

2015-01-03 Thread D.M. Procida
In 2015, DjangoCon Europe is coming to Cardiff:
 - the first-ever six-day DjangoCon.

The conference will begin with an open day (as in, open to anyone who
feels like coming) of free talks and tutorials, aimed at introducing new
people to Python and Django and the communities around them.

Registration's now open:


Hope to see you there. Maybe someone can even do a lightning talk about
comp.lang.python to introduce all the young whippersnappers to Usenet...

Daniele
-- 
DjangoCon Europe 2015 in Cardiff, 2nd to 7th June. 
Six days of talks, tutorials and code.


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


Socket programming

2015-01-03 Thread pramod gowda
Hi i am learning socket programming,

client code:

import socket

client_socket=socket.socket()
server_address='192.168.2.2'
server_port= 80
print("hello")
client_socket.connect((server_address,server_port))
print("hello")
data=client_socket.recv(1024)
print(data)
client_socket.close()

server code:
import socket

server_socket=socket.socket()
server_name='192.168.2.2'
server_port= 80
server_socket.bind((server_name,server_port))
server_socket.listen(1)

while True:
print("hello")
c,address=server_socket.accept()
print("we got connection from:",address)
c.send("hello,hw ru")
c.close()




I am not getting the output, i am using windows 7 OS..
please  check and give me the solution.
-- 
https://mail.python.org/mailman/listinfo/python-list


pathlib type error

2015-01-03 Thread Georg Grafendorfer
Hi

I'm using Debian 8 Jessie on an AMD64 machine.
Getting this error:

~$ python3
Python 3.4.2 (default, Oct  8 2014, 10:45:20)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pathlib import Path
>>> p = Path("/etc")
>>> q = p / "init.d"
Traceback (most recent call last):
  File "", line 1, in 
TypeError: unsupported operand type(s) for /: 'PosixPath' and 'str'
>>>


This also happens if I compile python3.4.2 from scratch:

.../data/Python-3.4.2$ ./python
Python 3.4.2 (default, Jan  3 2015, 12:42:09)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pathlib import Path
>>> p = Path("/etc")
>>> q = p / "init.d"
Traceback (most recent call last):
  File "", line 1, in 
TypeError: unsupported operand type(s) for /: 'PosixPath' and 'str'
>>>


On the same computer, using rescuecd 4.4.1 (Nov 2014) which ships python
3.4.1 it works as expected.

thanks for help, Georg
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Socket programming

2015-01-03 Thread Chris Angelico
On Sat, Jan 3, 2015 at 10:43 PM, pramod gowda  wrote:
> I am not getting the output, i am using windows 7 OS..
> please  check and give me the solution.

Windows 7 - that's part of the story. What version of Python are you
using? Is 192.168.2.2 the correct IP address? What happens when you
run these? Do you get exceptions?

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


Re: pathlib type error

2015-01-03 Thread Chris Angelico
On Sat, Jan 3, 2015 at 10:55 PM, Georg Grafendorfer
 wrote:
> I'm using Debian 8 Jessie on an AMD64 machine.
> Getting this error:
>
> ~$ python3
> Python 3.4.2 (default, Oct  8 2014, 10:45:20)
> [GCC 4.9.1] on linux
> Type "help", "copyright", "credits" or "license" for more information.
 from pathlib import Path
 p = Path("/etc")
 q = p / "init.d"
> Traceback (most recent call last):
>   File "", line 1, in 
> TypeError: unsupported operand type(s) for /: 'PosixPath' and 'str'


Unable to reproduce:

rosuav@dewey:~$ python3
Python 3.4.2 (default, Oct  8 2014, 10:45:20)
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pathlib import Path
>>> p = Path("/etc")
>>> q = p / "init.d"
>>> q
PosixPath('/etc/init.d')
>>> pathlib.__file__
'/usr/lib/python3.4/pathlib.py'

Is it possible you have another pathlib installed? It's available on
PyPI, maybe you got it with pip - check 'pip freeze|grep pathlib' on
the off-chance. Is your pathlib.__file__ the same as mine?

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


Re: pathlib type error

2015-01-03 Thread Chris Angelico
On Sat, Jan 3, 2015 at 11:06 PM, Chris Angelico  wrote:
> On Sat, Jan 3, 2015 at 10:55 PM, Georg Grafendorfer
>  wrote:
>> I'm using Debian 8 Jessie on an AMD64 machine.
>> Getting this error:
>>
>> ~$ python3
>> Python 3.4.2 (default, Oct  8 2014, 10:45:20)
>> [GCC 4.9.1] on linux
>
> Unable to reproduce:
>
> rosuav@dewey:~$ python3
> Python 3.4.2 (default, Oct  8 2014, 10:45:20)
> [GCC 4.9.1] on linux

Should have clarified: Dewey is also running Debian Jessie.

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


Re: Socket programming

2015-01-03 Thread pramod gowda
On Saturday, January 3, 2015 5:26:27 PM UTC+5:30, Chris Angelico wrote:
> On Sat, Jan 3, 2015 at 10:43 PM, pramod gowda  wrote:
> > I am not getting the output, i am using windows 7 OS..
> > please  check and give me the solution.
> 
> Windows 7 - that's part of the story. What version of Python are you
> using? Is 192.168.2.2 the correct IP address? What happens when you
> run these? Do you get exceptions?
> 
> ChrisA

Hi chris.


I am using python 3.4.2
I don get any exceptions,
but wn i run the code,i don see any connections, IP address is given as my 
system IP.

 c,address=server_socket.accept() in server.py..if am trying to print 
something,it fails
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Socket programming

2015-01-03 Thread Chris Angelico
On Sat, Jan 3, 2015 at 11:25 PM, pramod gowda  wrote:
> I am using python 3.4.2
> I don get any exceptions,
> but wn i run the code,i don see any connections, IP address is given as my 
> system IP.

What does the client say?

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


Re: Socket programming

2015-01-03 Thread pramod gowda
On Saturday, January 3, 2015 6:08:28 PM UTC+5:30, Chris Angelico wrote:
> On Sat, Jan 3, 2015 at 11:25 PM, pramod gowda  wrote:
> > I am using python 3.4.2
> > I don get any exceptions,
> > but wn i run the code,i don see any connections, IP address is given as my 
> > system IP.
> 
> What does the client say?
> 
> ChrisA

After  c,address=server_socket.accept()  ,this line of code,nothing s being 
executed.

example i am just trying to print "Hello"
thts also not being printed
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Command Line Inputs from Windows

2015-01-03 Thread Gisle Vanem

Ken Stewart wrote:


Here is a sample key:
S1-5-21-1560217580-722697556-320042093-1000-Classes
py_auto_file
shell
open
command

The corrected data for the key looks like this:

"C:\Python34\python.exe" %1 %*



Yikes! You use the awful cmd.exe as the shell don't you?
An advice is to use something like TakeCommand or 4NT (from jpsoft.com)
and create an "executable extension" for .py/.pyw files. Like I've
done:
 set .py=C:\Python34\python.exe
 set .pyw=C:\Python34\pythonw.exe

No need to fiddle with registry settings.

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


Re: Socket programming

2015-01-03 Thread mm0fmf

On 03/01/2015 11:43, pramod gowda wrote:

server_socket=socket.socket()
server_name='192.168.2.2'
server_port= 80
server_socket.bind((server_name,server_port))
server_socket.listen(1)


I don't do much Python on Windows but do you have the necessary access 
rights to open a listening socket on port 80? Don't you need to run this 
with Administrator rights?





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


Re: Socket programming

2015-01-03 Thread pramod gowda
On Saturday, January 3, 2015 8:39:26 PM UTC+5:30, mm0fmf wrote:
> On 03/01/2015 11:43, pramod gowda wrote:
> > server_socket=socket.socket()
> > server_name='192.168.2.2'
> > server_port= 80
> > server_socket.bind((server_name,server_port))
> > server_socket.listen(1)
> 
> I don't do much Python on Windows but do you have the necessary access 
> rights to open a listening socket on port 80? Don't you need to run this 
> with Administrator rights?

HI, i m doing n personal laptop.
so i think i ve rights to open a listening socket,could u pls tell me hw can i 
check it?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Socket programming

2015-01-03 Thread Steven D'Aprano
pramod gowda wrote:

> HI, i m doing n personal laptop.
> so i think i ve rights to open a listening socket,could u pls tell me hw
> can i check it?

Is your keyboard broken? There are a lot of missing characters in your
sentences. You're going to have a lot of trouble programming with a broken
keyboard.

As far as sockets, this is a Python discussion group, not Windows experts.
Try googling for more information and see if that helps:

https://duckduckgo.com/?q=windows%20permission%20to%20open%20sockets




-- 
Steven

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


Re: Socket programming

2015-01-03 Thread pramod gowda
On Saturday, January 3, 2015 9:27:20 PM UTC+5:30, Steven D'Aprano wrote:
> pramod gowda wrote:
> 
> > HI, i m doing n personal laptop.
> > so i think i ve rights to open a listening socket,could u pls tell me hw
> > can i check it?
> 
> Is your keyboard broken? There are a lot of missing characters in your
> sentences. You're going to have a lot of trouble programming with a broken
> keyboard.
> 
> As far as sockets, this is a Python discussion group, not Windows experts.
> Try googling for more information and see if that helps:
> 
> https://duckduckgo.com/?q=windows%20permission%20to%20open%20sockets
> 
> 
> 
> 
> -- 
> Steven

Hi Steven,


Sorry for using short words while posting,I am using python in windows7 with 
Python ver 3.4.2 for socket program,so i am asking for help.

Thanks
Pramod SP

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


Re: [ANN] EasyGUI_Qt version 0.9

2015-01-03 Thread André Roberge
On Saturday, 3 January 2015 04:52:21 UTC-4, wxjm...@gmail.com  wrote:
> Le vendredi 2 janvier 2015 20:11:25 UTC+1, André Roberge a écrit :
> > On Friday, 2 January 2015 06:29:37 UTC-4, wxjm...@gmail.com  wrote:
> > > Le mercredi 31 décembre 2014 23:24:50 UTC+1, André Roberge a écrit :
> > > > EasyGUI_Qt version 0.9 has been released.  This is the first 
> > > > announcement about EasyGUI_Qt on this list.
> > snip
> > > I toyed and I spent a couple of hours with it.
> > > I do not know to much what to say.
> > Well, this is more positive than your previous comment expressing doubt 
> > that it would work. ;-)   So, thank you!
> 
> Do not get me wrong, I do not wish to be rude.
> You are building a tool upon a toolkit which
> simply does not work properly.
> 
> If for some reason you are not aware of this,
> you are not aware of this, it is unfortunately
> a simple as this.
> 
> (Not only I know why, I'm able to explain the
> cause).

Would you care to elaborate?  All the code I have written works correctly on 
all the tests I have done.  I do have reports from a user using a Mac with 
Python 2.7 for which some widgets did not quite work properly ... but that's 
all I have heard about problems with it. 

I would like to hear about the problems you know about either here, on by 
filing an issue at https://github.com/aroberge/easygui_qt/issues
> 
> jmf
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Socket programming

2015-01-03 Thread Dan Stromberg
On Sat, Jan 3, 2015 at 3:43 AM, pramod gowda  wrote:
> Hi i am learning socket programming,

This "works" on Linux Mint 17.1.

Server:
#!/usr/local/cpython-3.4/bin/python

import socket

server_socket = socket.socket()
#server_name = '192.168.2.2'
server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
server_name = 'localhost'
server_port = 8080
server_socket.bind((server_name, server_port))
server_socket.listen(1)

while True:
print("hello")
c,address = server_socket.accept()
print("we got connection from:",address)
c.send(b"hello,hw ru")
c.close()


client:
#!/usr/local/cpython-3.4/bin/python

import socket

client_socket = socket.socket()
#server_address='192.168.2.2'
server_address = 'localhost'
server_port = 8080
print("hello")
client_socket.connect((server_address,server_port))
print("hello")
data=client_socket.recv(1024)
print(data)
client_socket.close()


But note that if you send 10 bytes into a socket, it could be received
as two chunks of 5, or other strangeness. So you should frame your
data somehow - adding crlf to the end of your send's is one simple
way.  There are multiple ways of dealing with this.  Here's one:
http://stromberg.dnsalias.org/~strombrg/bufsock.html with links to
others.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [ANN] EasyGUI_Qt version 0.9

2015-01-03 Thread Mark Lawrence

On 03/01/2015 17:11, André Roberge wrote:

On Saturday, 3 January 2015 04:52:21 UTC-4, wxjm...@gmail.com  wrote:

Le vendredi 2 janvier 2015 20:11:25 UTC+1, André Roberge a écrit :

On Friday, 2 January 2015 06:29:37 UTC-4, wxjm...@gmail.com  wrote:

Le mercredi 31 décembre 2014 23:24:50 UTC+1, André Roberge a écrit :

EasyGUI_Qt version 0.9 has been released.  This is the first announcement about 
EasyGUI_Qt on this list.

snip

I toyed and I spent a couple of hours with it.
I do not know to much what to say.

Well, this is more positive than your previous comment expressing doubt that it 
would work. ;-)   So, thank you!


Do not get me wrong, I do not wish to be rude.
You are building a tool upon a toolkit which
simply does not work properly.

If for some reason you are not aware of this,
you are not aware of this, it is unfortunately
a simple as this.

(Not only I know why, I'm able to explain the
cause).


Would you care to elaborate?  All the code I have written works correctly on 
all the tests I have done.  I do have reports from a user using a Mac with 
Python 2.7 for which some widgets did not quite work properly ... but that's 
all I have heard about problems with it.

I would like to hear about the problems you know about either here, on by 
filing an issue at https://github.com/aroberge/easygui_qt/issues


jmf


I hope you know that you're engaging with a person who makes statements 
about the inadequacies of various tools, but when challenged to provide 
evidence to support his claims he can never do so.  He is our "Resident 
Unicode Expert", in other words when it comes to Unicode he hasn't got 
the faintest idea what he's talking about, at least with respect to PEP 
393 and the Flexible String Representation.  Please ignore him as he's 
just not worth the effort.


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

Mark Lawrence

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


Re: How do I remove/unlink wildcarded files

2015-01-03 Thread Rick Johnson
On Saturday, January 3, 2015 4:39:25 AM UTC-6, Mark Lawrence wrote:

> I used to get very confused watching the old westerns.  The child when 
> talking about "more" and "paw" wasn't referring to possibly an 
> adjective, noun or adverb and a part of an animal, but what we would 
> refer to in the UK as "mum" and "dad" :)

Early Americans are easy to satirize since most were
schooled at home by illiterate parents. I believe the
"redneck vernacular" substituted "mother" and "father" for
"maw" and "paw" respectively. Which is not surprising since
most uneducated folks tend to favor single syllable
simplifications of words over their multi-syllable
counterparts.

Widespread centralized free schooling did not exists until
almost the 1900's. Heck, looking back at American history,
the world *SHOULD* be in awe. To go from a rag-tag
illiterate bunch of cowboys, to the worlds most powerful and
technically advanced society (in roughly one hundred years!)
has to be the most amazing transformation in the history of
the human society.

Of course with all success stories, timing and luck had a
little to do with it, but it was undoubtedly the rebellious
and self reliant nature of Americans that made them so
successful. So before you go and spouting off about how dumb
Americans are/were, ask yourself, what greatness has *MY*
country achieved in the span of a century?

*school bell rings*

PS: I've recently developed an industrial grade scraper
specially designed for removing dried egg residue from the
human face with a "minimal" amount of collateral damage. If
any of you are interested in volunteering your egg covered
faces for testing i would be thankful! Please send me a
private message as the alpha phase begins soon!


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


Re: Python Tk Tix GUI documentation & builder overview and tips

2015-01-03 Thread abaskm
Hi,

I have had issues running Tix on python 2.7.6 and 3.4.2:

More details on the issue here.

http://stackoverflow.com/questions/27751923/tix-widgets-installation-issue

Has anyone had similar issues with Tix?

Thanks and Happy New Year.


On Friday, March 27, 2009 5:19:42 PM UTC-4, bal...@googlemail.com wrote:
> I have recently started development for a small video conversion
> project using a GUI. After some research I decided to use Tkinter/Tix
> (Tk/Tix). The reasons are mainly:
> 
> 1. the GUI is rather simple, and
> 
> 2. the end-user is not necessarily technically inclined so I want to
> keep
>   a) required libraries as few as possible, and
>   b) installation as painless as possible.
> 
> 3. Tk/Tix is included with Python. Thus only a Python installation is
> needed. Nothing else.
> 
> 4. Tk itsself misses some rudimentary widgets like meters, multi/colum
> lists, grid and scrolled widgets. Tix provides those. Good enough for
> my little application (more advanced and more modern widgets are
> available in frameworks like Qt, Gtk, or wxWindows).
> 
> 
> Before starting I spent some effort to find
> a) relevant documentation,
> b) GUI Builders which might help me,
> c) answers to non-obvious questions.
> 
> The process took some time and effort so I want to share my findings:
> 
> a) Documentation resources
> 
> Python Docs
> http://docs.python.org/library/tkinter.html
> Tk Commands
> http://www.tcl.tk/man/tcl8.5/TkCmd/contents.htm
> Tix Reference
> http://tix.sourceforge.net/man/html/contents.htm
> Tix demo application
>   You want to extract the Tix demo application coming with the Tix
> 8.4.3 source distribution. It containsexamples for many widgets -
> unfortunately none for multi-column HList or the Grid (see below).
>   
> https://sourceforge.net/project/showfiles.php?group_id=5649&package_id=5704
>   Tix8.4.3-src.tar.gz, then look in /Tix8.4.3/Python/Demo/tix
> Thinking in Tkinter
>   I recommend the "Individual programs online"
>   http://www.ferg.org/thinking_in_tkinter/index.html
> 
> 
> b) GUI development tools
> 
> ActiveState GUI Builder (using grid layout)
>   SpecTcl is the predecessor of GUI Builder (by ActivaState).
> http://spectcl.sourceforge.net/
> FAQ (where to get source)
> http://aspn.activestate.com/ASPN/Mail/Message/komodo-announce/3355346
> 
> PAGE v3.0 by Stewart Allen (using placer layout)
> http://page.sourceforge.net/
> 
> There are many more for other GUI toolkits mentioned in this post:
>   http://mail.python.org/pipermail/python-list/2004-February/250727.html
> 
> Finally I decided to use the packer layout and create the widgets
> manually. Just the simplest and quickest way for me.
> 
> 
> c) How do I ...?
> 
> How do I use all methods available in the Tix Grid?
> 
> Tix Grid with full implementation of all methods
> http://klappnase.bubble.org/TixGrid/index.html
> 
> 
> How do I create a multi-column Tix.HList?
> 
>   import Tkinter as Tk
>   import Tix
> 
>   root = Tix.Tk()
>   # setup HList
> hl = Tix.HList(root, columns = 5, header = True)
> hl.header_create(0, text = "File")
> hl.header_create(1, text = "Date")
> hl.header_create(1, text = "Size")
>   # create a multi-column row
>   hl.add("row1", text = "filename.txt")
>   hl.item_create(entry_path, 1, text = "2009-03-26 21:07:03")
>   hl.item_create(entry_path, 2, text = "200MiB")
> 
> I haven't found out how to right-justify individual columns? Anyone?
> 
> 
> How to implement Tk GUI with multiple threads?
> 
> Usually there are two options to make threads wait for an event:
> 
>   * gui thread polling (lame)
> see here how to use Tk.after() (actually a Tcl command) to poll
>   http://uucode.com/texts/pylongopgui/pyguiapp.html
> 
> see here how to imitate the Tk event loop to poll for non-Tk
> events (a socket, for example)
>   
> https://sourceforge.net/project/showfiles.php?group_id=5649&package_id=5704
>   Tix8.4.3-src.tar.gz, then look in /Tix8.4.3/Python/Demo/tix/
> tixwidgets.py, find loop()
> 
> 
>   * multithreaded with events (the option to choose)
> Basically this uses bind and event_generate to send "Notify"
> messages to the Tk instance.
> I suspect the following example failed due to not synchronising
> the event_generate call
> 
> http://coding.derkeiler.com/Archive/Python/comp.lang.python/2006-07/msg01479.html
> 
> For multithreading Python Tk GUI applications the following rules
> apply:
> 1. same thread calling Tk must do all subsequent GUI calls,
> 2. other threads may send events with send_event to the root Tk
> instance,
> 3. with threading problems you might try to synchonise access to
> event_generate(). Using event_generate() with one non-GUI thread seems
> to be safe.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do I remove/unlink wildcarded files

2015-01-03 Thread Mark Lawrence

On 03/01/2015 17:53, Rick Johnson wrote:

On Saturday, January 3, 2015 4:39:25 AM UTC-6, Mark Lawrence wrote:


I used to get very confused watching the old westerns.  The child when
talking about "more" and "paw" wasn't referring to possibly an
adjective, noun or adverb and a part of an animal, but what we would
refer to in the UK as "mum" and "dad" :)


Early Americans are easy to satirize since most were
schooled at home by illiterate parents. I believe the
"redneck vernacular" substituted "mother" and "father" for
"maw" and "paw" respectively. Which is not surprising since
most uneducated folks tend to favor single syllable
simplifications of words over their multi-syllable
counterparts.

Widespread centralized free schooling did not exists until
almost the 1900's. Heck, looking back at American history,
the world *SHOULD* be in awe. To go from a rag-tag
illiterate bunch of cowboys, to the worlds most powerful and
technically advanced society (in roughly one hundred years!)
has to be the most amazing transformation in the history of
the human society.


I suspect that the engineers who pushed the railways across North 
America were hardly "a rag-tag illiterate bunch of cowboys".  I won't 
mention that the transformation involved wiping out 99% of the 
indigenous population.




Of course with all success stories, timing and luck had a
little to do with it, but it was undoubtedly the rebellious
and self reliant nature of Americans that made them so
successful. So before you go and spouting off about how dumb
Americans are/were, ask yourself, what greatness has *MY*
country achieved in the span of a century?


I'm not entirely sure how a little bit of gentle teasing about accents 
in fictional films translates into "spouting off about how dumb 
Americans are/were" but there you go.  Hardly a century but I believe 
that the British Empire covered 25% of the land surface on the planet. 
Quite an achievement for a tiny patch of islands sitting off the coast 
of Europe.  However I suspect that a large number of people were glad to 
see the back of us, although I still think it audacious for those people 
to actually want to run their own countries.




*school bell rings*

PS: I've recently developed an industrial grade scraper
specially designed for removing dried egg residue from the
human face with a "minimal" amount of collateral damage. If
any of you are interested in volunteering your egg covered
faces for testing i would be thankful! Please send me a
private message as the alpha phase begins soon!



I believe that this has already been done.  Should I ever need one I'll 
probably get a cheap one, complete with its "Made in China" sticker, 
from one of the many £ stores that are springing up in the UK.


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

Mark Lawrence

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


surprise - byte in set

2015-01-03 Thread patrick vrijlandt

Hello list,

Let me first wish you all the best in 2015!

Today I was trying to test for occurrence of a byte in a set ...

>>> sys.version
'3.4.2 (v3.4.2:ab2c023a9432, Oct  6 2014, 22:15:05) [MSC v.1600 32 bit 
(Intel)]'

>>> 'b' in 'abc'
True
>>> b'b' in b'abc'
True
>>> 'b' in set('abc')
True
>>> b'b' in set(b'abc')
False

I was surprised by the last result. What happened?
(Examples simplified; I was planning to manipulate the set)

Patrick

---
Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware.
http://www.avast.com

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


Re: surprise - byte in set

2015-01-03 Thread Jason Friedman
 sys.version
> '3.4.2 (v3.4.2:ab2c023a9432, Oct  6 2014, 22:15:05) [MSC v.1600 32 bit
> (Intel)]'
 'b' in 'abc'
> True
 b'b' in b'abc'
> True
 'b' in set('abc')
> True
 b'b' in set(b'abc')
> False
>
> I was surprised by the last result. What happened?
> (Examples simplified; I was planning to manipulate the set)

I'm no expert, but I see:

>>> for i in set(b'abc'):
... print(type(i))
...



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


Re: surprise - byte in set

2015-01-03 Thread Dan Stromberg
On Sat, Jan 3, 2015 at 10:50 AM, patrick vrijlandt  wrote:
> Hello list,
>
> Let me first wish you all the best in 2015!
>
> Today I was trying to test for occurrence of a byte in a set ...


In the last case, the set has integers in it.

Try:
b'b'[0] in set(b'abc')
-- 
https://mail.python.org/mailman/listinfo/python-list


Put float number in message.

2015-01-03 Thread John Culleton
Here is my last line in a simple program that is a scribus script.
end = scribus.messageBox('Book Spine Width', 'dummy', ICON_WARNING, BUTTON_OK)

This works. Now I want to put a float number called S instead of 'dummy'.
If I just put S in the command I get an error. If I convert S to a string with
SS = str(S)
first and then 
and substitute SS for 'dummy' I get what appears to be the ASCII numbers 
representing the characters, not the characters I want. 

I am a total newbie with Python. Anyone have a suggestion? Can I use a print 
command instead?

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


Re: surprise - byte in set

2015-01-03 Thread Gary Herron

On 01/03/2015 10:50 AM, patrick vrijlandt wrote:

Hello list,

Let me first wish you all the best in 2015!

Today I was trying to test for occurrence of a byte in a set ...

>>> sys.version
'3.4.2 (v3.4.2:ab2c023a9432, Oct  6 2014, 22:15:05) [MSC v.1600 32 bit 
(Intel)]'

>>> 'b' in 'abc'
True
>>> b'b' in b'abc'
True
>>> 'b' in set('abc')
True
>>> b'b' in set(b'abc')
False

I was surprised by the last result. What happened?
(Examples simplified; I was planning to manipulate the set)


The surprise is really that the 3rd test is True not that the fourth is 
False.


First, as should be expected, a byte string is a sequence of (small) 
ints.  So b'b' is a (short) byte string and the set set(b'abc') is 
composed of three ints.  You should not expect your inclusion test to 
return True when testing for a bytes-type object in a set of int-type 
objects.  And that explains your False result in the 4th test.


>>> type(b'abc')

>>> type(b'abc'[0])



But things are different for strings.  You might think a string is a 
sequence of characters, but Python does not have a character type. In 
fact the elements of a string are just 1 char long strings:


>>> type('abc')

>>> type('abc'[0])


You would not logically expect to find a string 'b' in a set of 
characters in, say C++,  where the two types are different.  But that's 
not the Python way.  In Python a set of characters set('abc') is really 
a set of (short) strings, and the character 'b' is really a (short) 
string, so the inclusion test works.


Python's way of returning a 1-byte string when indexing a string 
(instead of returning an element of type character) allows this 
surprising result.


>>> 'abc'[0]
'a'
>>> 'abc'[0][0]
'a'
>>> 'abc'[0][0][0]
'a'
>>> 'abc'[0][0][0][0]
'a'
...


I've never considered this a problem, but a infinitely indexable object 
*is* a bit of an oddity.







Patrick

---
Dit e-mailbericht is gecontroleerd op virussen met Avast 
antivirussoftware.

http://www.avast.com




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

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


apostrophe not considered with tkinter's wordstart and wordend

2015-01-03 Thread ravas
When I place my mouse over a word (and I press something) 
I want the program to analyze the word.
Tkinter almost provides the perfect option:
self.text.get('current wordstart', 'current wordend')

Unfortunately apostrophes are not considered using wordstart and wordend.
http://infohost.nmt.edu/tcc/help/pubs/tkinter/
Says: 
"For the purposes of this operation, a word is either 
a string of consecutive letter, digit, or underbar (_) characters, 
or a single character that is none of these types."

The easy work around is to highlight the word and use:
self.text.get('sel.first', 'sel.last')

However, it seems like it could be an easy improvement 
if we could include the apostrophe in the list of word characters.
Is it possible that this could be added in an upcoming version of Python -- 
or is this a Tk issue?


Windows 7 & Python 3.4
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Put float number in message.

2015-01-03 Thread Mark Lawrence

On 03/01/2015 19:23, John Culleton wrote:

Here is my last line in a simple program that is a scribus script.
end = scribus.messageBox('Book Spine Width', 'dummy', ICON_WARNING, BUTTON_OK)

This works. Now I want to put a float number called S instead of 'dummy'.
If I just put S in the command I get an error. If I convert S to a string with
SS = str(S)
first and then
and substitute SS for 'dummy' I get what appears to be the ASCII numbers 
representing the characters, not the characters I want.

I am a total newbie with Python. Anyone have a suggestion? Can I use a print 
command instead?

John Culleton



I think you just want some string formatting so (untested) either

end = scribus.messageBox('Book Spine Width', '{}'.format(S), 
ICON_WARNING, BUTTON_OK)


or

end = scribus.messageBox('Book Spine Width', '%f' % S, ICON_WARNING, 
BUTTON_OK)


For all the formatting options see 
https://docs.python.org/3/library/string.html#string-formatting or 
https://docs.python.org/3/library/stdtypes.html#old-string-formatting 
respectively.


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

Mark Lawrence

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


Re: apostrophe not considered with tkinter's wordstart and wordend

2015-01-03 Thread Peter Otten
ravas wrote:

> When I place my mouse over a word (and I press something)
> I want the program to analyze the word.
> Tkinter almost provides the perfect option:
> self.text.get('current wordstart', 'current wordend')
> 
> Unfortunately apostrophes are not considered using wordstart and wordend.
> http://infohost.nmt.edu/tcc/help/pubs/tkinter/
> Says:
> "For the purposes of this operation, a word is either
> a string of consecutive letter, digit, or underbar (_) characters,
> or a single character that is none of these types."
> 
> The easy work around is to highlight the word and use:
> self.text.get('sel.first', 'sel.last')
> 
> However, it seems like it could be an easy improvement
> if we could include the apostrophe in the list of word characters.
> Is it possible that this could be added in an upcoming version of Python
> -- or is this a Tk issue?

I think it is.

 does not mention a way to 
configure the set of word chars either:

"""
?submodifier? wordstart
Adjust the index to refer to the first character of the word containing the 
current index. A word consists of any number of adjacent characters that are 
letters, digits, or underscores, or a single character that is not one of 
these. If the display submodifier is given, this only examines non-elided 
characters, otherwise all characters (elided or not) are examined.
"""


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


Re: Python Tk Tix GUI documentation & builder overview and tips

2015-01-03 Thread Terry Reedy

On 1/3/2015 1:30 PM, aba...@gmail.com wrote:

Hi,

I have had issues running Tix on python 2.7.6 and 3.4.2:

More details on the issue here.

http://stackoverflow.com/questions/27751923/tix-widgets-installation-issue

Has anyone had similar issues with Tix?


The current doc is wrong in any case.  I opened
http://bugs.python.org/issue23156

--
Terry Jan Reedy

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


Re: surprise - byte in set

2015-01-03 Thread patrick vrijlandt

Dear all,

Many thanks for your responses. I never realised this difference between 
'bytes' and 'string'.


Thanks,

Patrick

---
Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware.
http://www.avast.com

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


Re: Enumerating loggers iin logging module

2015-01-03 Thread John Pote
Thanks for the replies, thought there'd be a simple answer. Much 
appreciated.

John

On 30/12/2014 22:40, Chris Angelico wrote:

On Wed, Dec 31, 2014 at 8:24 AM, Tim Chase
 wrote:

While it may involve reaching into the objects may or may not be
blessed, the following seems to work for me in Py2.7:

   >>> import logging
   >>> # add a bunch of loggers and sub-loggers
   >>> print logging.Logger.manager.loggerDict.keys()

Works in 3.5, too, aside from trivialities:

$ python3
Python 3.5.0a0 (default:1c51f1650c42+, Dec 29 2014, 02:29:06)
[GCC 4.7.2] on linux
Type "help", "copyright", "credits" or "license" for more information.

import logging
logging.getLogger("Name")



logging.getLogger("name.sublogger")



logging.Logger.manager.loggerDict

{'name.sublogger': , 'Name':
, 'name':
}

I'd say this is fine for debugging with.

ChrisA


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


list comparison vs integer comparison, which is more efficient?

2015-01-03 Thread austin aigbe
Hi,

I am currently implementing the LTE physical layer in Python (ver 2.7.7).
For the qpsk, 16qam and 64qam modulation I would like to know which is more 
efficient to use, between an integer comparison and a list comparison:

Integer comparison: bit_pair as an integer value before comparison

# QPSK - TS 36.211 V12.2.0, section 7.1.2, Table 7.1.2-1
def mp_qpsk(self):
r = []
for i in range(self.nbits/2):
bit_pair = (self.sbits[i*2] << 1) | self.sbits[i*2+1] 
if bit_pair == 0:
r.append(complex(1/math.sqrt(2),1/math.sqrt(2)))
elif bit_pair == 1:
r.append(complex(1/math.sqrt(2),-1/math.sqrt(2)))
elif bit_pair == 2:
r.append(complex(-1/math.sqrt(2),1/math.sqrt(2)))
elif bit_pair == 3:
r.append(complex(-1/math.sqrt(2),-1/math.sqrt(2)))
return r

List comparison: bit_pair as a list before comparison

# QPSK - TS 36.211 V12.2.0, section 7.1.2, Table 7.1.2-1
def mp_qpsk(self):
r = []
for i in range(self.nbits/2):
bit_pair = self.sbits[i*2:i*2+2] 
if bit_pair == [0,0]:
r.append(complex(1/math.sqrt(2),1/math.sqrt(2)))
elif bit_pair == [0,1]:
r.append(complex(1/math.sqrt(2),-1/math.sqrt(2)))
elif bit_pair == [1,0]:
r.append(complex(-1/math.sqrt(2),1/math.sqrt(2)))
elif bit_pair == [1,1]:
r.append(complex(-1/math.sqrt(2),-1/math.sqrt(2)))
return r

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


Re: [ANN] EasyGUI_Qt version 0.9

2015-01-03 Thread Michael Torrie
On 01/03/2015 10:11 AM, André Roberge wrote:
> Would you care to elaborate?  All the code I have written works
> correctly on all the tests I have done.  I do have reports from a
> user using a Mac with Python 2.7 for which some widgets did not quite
> work properly ... but that's all I have heard about problems with it.
> 
> 
> I would like to hear about the problems you know about either here,
> on by filing an issue at
> https://github.com/aroberge/easygui_qt/issues

It's not clear to me that jmf even understands what easygui is intended
to do.  So I wouldn't worry too much about what he says.  So I'd just
ignore what he has to say.  If someone needs a full event-driven GUI,
they can use an appropriate toolkit.  For quick and dirty little
utilities I can see how easygui fits the bill, and being Qt-based is
good news.

By the way, I'm not seeing jmf's emails; I think they are being filtered
at the mailing list level.  I think enough people got tired of his
trolling that they banned him, though on USENET he's still getting through.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: list comparison vs integer comparison, which is more efficient?

2015-01-03 Thread Chris Angelico
On Sun, Jan 4, 2015 at 10:19 AM, austin aigbe  wrote:
> I would like to know which is more efficient to use, between an integer 
> comparison and a list comparison:

You can test them with the timeit module, but my personal suspicion is
that any difference between them will be utterly and completely
dwarfed by all your sqrt(2) calls in the complex constructors. If you
break those out, and use a tuple instead of a list, you could write
this very simply and tidily:

bits = {
(0,0): complex(1/math.sqrt(2),1/math.sqrt(2)),
(0,1): complex(1/math.sqrt(2),-1/math.sqrt(2)),
(1,0): complex(-1/math.sqrt(2),1/math.sqrt(2)),
(1,1): complex(-1/math.sqrt(2),-1/math.sqrt(2)),
}
# QPSK - TS 36.211 V12.2.0, section 7.1.2, Table 7.1.2-1
def mp_qpsk(self):
r = []
for i in range(self.nbits/2):
bit_pair = self.sbits[i*2:i*2+2]
r.append(bits[tuple(bit_pair)])
return r

At this point, your loop looks very much like a list comprehension in
full form, so you can make a simple conversion:

# From itertools recipes
# https://docs.python.org/3/library/itertools.html
def pairwise(iterable):
"s -> (s0,s1), (s1,s2), (s2, s3), ..."
a, b = tee(iterable)
next(b, None)
return zip(a, b)
# Replace zip() with izip() for the Python 2 equivalent.

def mp_qpsk(self):
return [bits[pair] for pair in pairwise(self.sbits)]

How's that look? I don't care if it's faster or not, I prefer this form :)

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


Help with finding tutors for Python, Linux, R, Perl, Octave, MATLAB and/or Cytoscape for yeast microarray analysis, next generation sequencing and constructing gene interaction networks

2015-01-03 Thread thomas hahn
​​

*Help with finding tutors for Python, Linux, R, Perl, Octave, MATLAB and/or
Cytoscape for yeast microarray analysis, next generation sequencing and
constructing gene interaction networks*



Hi



I am a visually impaired bioinformatics graduate student using microarray
data for my master’s thesis aimed at deciphering the mechanism by which the
yeast wild type can suppress the rise of free reactive oxygen species (ROS)
induced by caloric restriction (CR) but the Atg15 and Erg6 knockout mutant
cannot.



Since my remaining vision is very limited I need very high magnification.
But that makes my visual field very small.  Therefore I need somebody to
teach me how to use these programming environments, especially for
microarray analysis, next generation sequencing and constructing gene and
pathway interaction networks.  This is very difficult for me to figure out
without assistance because Zoomtext, my magnification and text to speech
software, on which I am depending because I am almost blind, has problems
reading out aloud many programming related websites to me.  And even those
websites it can read, it can only read sequentially from left to right and
then from top to bottom.  Unfortunately, this way of acquiring, finding,
selecting and processing new information and answering questions is too
tiresome, exhausting, ineffective and especially way too time consuming for
graduating with a PhD in bioinformatics before my funding runs out despite
being severely limited by my visual disability.  I would also need help
with writing a good literature review and applying the described techniques
to my own yeast Affimetrix microarray dataset because I cannot see well
enough to find all relevant publications on my own.



Some examples for specific tasks I urgently need help with are:



1.Analyzing and comparing the three publically available microarray
datasets that can be accessed at:

A.http://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE41860

B.http://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE38635

C.   http://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc=GSE9217



2.Learning how to use the Affymetrics microarray analysis software for
the Yeast 2 chip, which can be found at
http://www.affymetrix.com/support/technical/libraryfilesmain.affx



3.For Cytoscape I need somebody, who can teach me how to execute the
tutorials at the following links because due to my very limited vision
field I cannot see tutorial and program interface simultaneously.

A.
http://opentutorials.cgl.ucsf.edu/index.php/Tutorial:Introduction_to_Cytoscape_3.1-part2#Importing_and_Exploring_Your_Data

B.
http://opentutorials.cgl.ucsf.edu/index.php/Tutorial:Filtering_and_Editing_in_Cytoscape_3

C.
http://cytoscape.org/manual/Cytoscape2_8Manual.html#Import%20Fixed-Format%20Network%20Files

D.   http://wiki.cytoscape.org/Cytoscape_User_Manual/Network_Formats



4.Learning how to use the TopGo R package to perform statistical
analysis on GO enrichments.



Since I am legally blind the rehab agency is giving me money to pay tutors
for this purpose.  Could you please help me getting in touch regarding this
with anybody, who could potentially be interested in teaching me one on one
thus saving me time for acquiring new information and skills, which I need
to finish my thesis on time, so that I can remain eligible for funding to
continue in my bioinformatics PhD program despite being almost blind?  The
tutoring can be done remotely via TeamViewer 5 and Skype.  Hence, it does
not matter where my tutors are physically located.  Currently I have tutors
in Croatia and UK.  But since they both work full time jobs while working
on their PhD dissertation they only have very limited time to teach me
online.  Could you therefore please forward this request for help to
anybody, who could potentially be interested or, who could connect me to
somebody, who might be, because my graduation and career depend on it?  Who
else would you recommend me to contact regarding this?  Where else could I
post this because I am in urgent need for help?



Could you please contact me directly via email at thomas.f.ha...@gmail.com
and/or Skype at tfh002 because my text to speech software has problems to
read out this website aloud to me?

I thank you very much in advance for your thoughts, ideas, suggestions,
recommendations, time, help, efforts and support.

With very warm regards,



*Thomas Hahn*

1)*Graduate student in the Joint Bioinformatics Program at the
University of Arkansas at Little Rock (UALR) and the University of Arkansas
Medical Sciences (UAMS) &*

2)*Research & Industry Advocate, Founder and Board Member of RADISH
MEDICAL SOLUTIONS, INC. (**http://www.radishmedical.com/thomas-hahn/*
*) *



*Primary email: **thomas.f.ha...@gmail.com* 

*Cell phone: 318 243 3940*

*Office phone: 501 682 1440*

*Office location: EIT 535*

*Skype ID: tfh002*

*Virtual Google Voice phone to reach me whi

Re: Help with finding tutors for Python, Linux, R, Perl, Octave, MATLAB and/or Cytoscape for yeast microarray analysis, next generation sequencing and constructing gene interaction networks

2015-01-03 Thread Rustom Mody
On Sunday, January 4, 2015 8:45:08 AM UTC+5:30, thomas hahn wrote:
> 
> 
> 
> 
> Help with finding tutors
> for Python, Linux, R, Perl, Octave, MATLAB and/or Cytoscape for yeast 
> microarray
> analysis, next generation sequencing and constructing gene interaction 
> networks

Hi Thomas

This is a reasonably friendly and generally knowledgeable place for python 
related questions.
Feel free to ask your questions here.

If you need help starting programming and python is your chosen medium
there is also a tutors list
https://mail.python.org/mailman/listinfo/tutor.

As for the rest...

Have a vague idea what yeast is
None whatever of cytospace
And probably think a 'microarray' other than what you do

[That was a joke. More seriously...]
Specialized areas of application of python are less likely to find help out here

That being the case, starting out with python needs a focussed approach
- Spend a few days getting into python
- Then worry about applying it to your needs

In your case you are not just starting python
but python perl R octave mathlab linux
In this manner you are setting yourself up for failure unless you have enough 
money to
hire people for all your programming work.

I can tell you that python ecosystem can offer most of what perl, R, octave 
mathlab offer. But for that you have to go beyond core python to things like
scipy, pandas etc.

Fans of perl, R, octave, mathlab will tell you the same for these as well

You may want to start by throwing a 5-sided coin.

Best wishes on your studies

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


Re: list comparison vs integer comparison, which is more efficient?

2015-01-03 Thread Terry Reedy

On 1/3/2015 6:19 PM, austin aigbe wrote:


I am currently implementing the LTE physical layer in Python (ver 2.7.7).
For the qpsk, 16qam and 64qam modulation I would like to know which is more 
efficient to use, between an integer comparison and a list comparison:

Integer comparison: bit_pair as an integer value before comparison

 # QPSK - TS 36.211 V12.2.0, section 7.1.2, Table 7.1.2-1
 def mp_qpsk(self):
 r = []
 for i in range(self.nbits/2):
 bit_pair = (self.sbits[i*2] << 1) | self.sbits[i*2+1]
 if bit_pair == 0:
 r.append(complex(1/math.sqrt(2),1/math.sqrt(2)))
 elif bit_pair == 1:
 r.append(complex(1/math.sqrt(2),-1/math.sqrt(2)))
 elif bit_pair == 2:
 r.append(complex(-1/math.sqrt(2),1/math.sqrt(2)))
 elif bit_pair == 3:
 r.append(complex(-1/math.sqrt(2),-1/math.sqrt(2)))
 return r

List comparison: bit_pair as a list before comparison

 # QPSK - TS 36.211 V12.2.0, section 7.1.2, Table 7.1.2-1
 def mp_qpsk(self):
 r = []
 for i in range(self.nbits/2):
 bit_pair = self.sbits[i*2:i*2+2]
 if bit_pair == [0,0]:
 r.append()
 elif bit_pair == [0,1]:
 r.append(complex(1/math.sqrt(2),-1/math.sqrt(2)))
 elif bit_pair == [1,0]:
 r.append(complex(-1/math.sqrt(2),1/math.sqrt(2)))
 elif bit_pair == [1,1]:
 r.append(complex(-1/math.sqrt(2),-1/math.sqrt(2)))
 return r


Wrong question.  If you are worried about efficiency, factor out all 
repeated calculation of constants and eliminate the multiple comparisons.


sbits = self.sbits
a = 1.0 / math.sqrt(2)
b = -a
points = (complex(a,a), complex(a,b), complex(b,a), complex(b,b))
complex(math.sqrt(2),1/math.sqrt(2))
def mp_qpsk(self):
r = [points[sbits[i]*2 + sbits[i+1]]
for i in range(0, self.nbits, 2)]
return r

--
Terry Jan Reedy

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