get return or locals from "exec" str in "environment"

2012-08-30 Thread lucas
ok, i am stuck.  i tried some test code attempts and i am stuck.  so here is 
some sample code:

xx2 = """
def lucas53():
  harry = (4+16)/2
  rtn = dict(harry=harry)
  return rtn
"""

and then i run:

env = {}
exec xx2 in env
lst = env

and lst returns a huge dictionary of many types, some excerpts are:
{...
...'globals': , ...
...'vars': , ...
...'locals': , ...
...'lucas53': }

and i can see my executed function in there as a type function, and local and 
global vars, but i can not access or find "harry" or "rtn" the variables within 
the function lucas53.  i do not know how to access the local variables within 
lucas53 or the locals to find harry or rtn.  i really just want the return 
dictionary.  make sense?

anyway, python impresses me with its graceful and concise code, but i really 
have not found the solution to this mess.

please advise and thank you in advance.  lucas
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: get return or locals from "exec" str in "environment"

2012-08-30 Thread lucas
> Far as I can see, you never actually called that function anywhere.
> ChrisA

doesn't the exec command call the function?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: get return or locals from "exec" str in "environment"

2012-08-30 Thread lucas
oh, yeah that was perfect.  got it working and it is graceful too.  sorry about 
the double post, i thought i was only posting to this one.

one final concern, if this code is running under a function in a 
multi-threaded, multi-session kind of environment, does exec cross threads or 
sessions?  like, i am afraid that i will get cross-over or bleeding into other 
threads or sessions.  does exec do that kind of common memory space wherein i 
have to be very very careful about executing such code and my daemon crashing 
or security holes and the like.

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


Re: get return or locals from "exec" str in "environment"

2012-08-30 Thread lucas
also, does that environment space, what i am assigning as env, have any such 
common memory space or cross thread problem with simultaneous threads or 
sessions?
-- 
http://mail.python.org/mailman/listinfo/python-list


XML RPC changes between 3.7 and 3.9 yield 401 http error

2021-02-24 Thread lucas

Hi everyone,

(Sorry for the double-send if any, i'm not sure the first send was 
performed, maybe because of bounce errors according to mailman.)



I'm currently trying to understand an error when using the 
dokuwikixmlrpc python module, allowing to easily work with DokuWiki RPC 
interface.


Another description of the problem :
https://github.com/kynan/dokuwikixmlrpc/issues/8

Here is the code, tailored to work with the DokuWiki RPC interface:

from urllib.parse import urlencode
import xmlrpc.client as xmlrpclib

URL = 'wiki.example.net'
USER = 'user'
PASSWD = 'password'
USER_AGENT = 'DokuWikiXMLRPC  1.0  for testing'

script = '/lib/exe/xmlrpc.php'
url = URL + script + '?' + urlencode({'u': USER, 'p': PASSWD})
xmlrpclib.Transport.user_agent = USER_AGENT
xmlrpclib.SafeTransport.user_agent = USER_AGENT
proxy = xmlrpclib.ServerProxy(url)

v = proxy.dokuwiki.getVersion()
print(v)

When ran with Python 3.7 (a personnal debian server, or a personal 
windows computer), i obtain the expected 'Release 2018-04-22a "Greebo"' 
as ouput.
When ran with Python 3.9 (my personnal, manjaro machine), i obtain the 
following stacktrace:


Traceback (most recent call last):
  File "/home/project/read.py", line 32, in 
v = proxy.dokuwiki.getVersion()
  File "/usr/lib/python3.9/xmlrpc/client.py", line 1116, in __call__
return self.__send(self.__name, args)
  File "/usr/lib/python3.9/xmlrpc/client.py", line 1456, in __request
response = self.__transport.request(
  File "/usr/lib/python3.9/xmlrpc/client.py", line 1160, in request
return self.single_request(host, handler, request_body, verbose)
  File "/usr/lib/python3.9/xmlrpc/client.py", line 1190, in 
single_request

raise ProtocolError(
xmlrpc.client.ProtocolError: wiki.example.net/lib/exe/xmlrpc.php: 401 Unauthorized>


I don't have the possibility to test this on python 3.8 specifically, 
but since the XML and XMLRPC modules have been updated in 3.8, and since 
3.9 doesn't seems to introduce any change for them, i would expect 3.8 
to introduce some change that dokuwikixmlrpc has somehow to take into 
consideration.


Can anyone help me with that one ? I don't know anything about RPC and 
XML, i don't know what i need to do know to fix dokuwikixmlrpc.


Best regard,
--lucas
--
https://mail.python.org/mailman/listinfo/python-list


Re: name for a mutually inclusive relationship

2021-02-24 Thread lucas

Hi !

In case you didn't though about that, in argparse, 
MutuallyExclusiveGroup is used for the mutually exclusive logic. You may 
use the same nomenclature, which happens to be IMHO much clearer than 
the one you came up with.


In GUIs, i guess that such an option would be implemented by a checkbox 
that, when checked, enables the widgets associated to all the mutually 
inclusive options.


Best regards,
--lucas


On 24/02/2021 17:12, Ethan Furman wrote:
I'm looking for a name for a group of options that, when one is 
specified, all of them must be specified.


For contrast,

- radio buttons: a group of options where only one can be specified 
(mutually exclusive)
- check boxes:   a group of options that are independent of each other 
(any number of

  them may be specified)

- ???: a group of options where, if one is specified, all must be 
specified (mutually

    inclusive)

So far, I have come up with:

- the Three Musketeers
- clique
- club
- best friends
- tight knit
- group

Is there a name out there already to describe that concept?

--
~Ethan~

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


Re: XML RPC changes between 3.7 and 3.9 yield 401 http error

2021-02-24 Thread lucas

Hi, thanks for your answer !

I updated everything, including certificates, while upgrading to python 
3.9, and retried today (no new certificates to install). I am the 
administrator of the wiki i try to access, and didn't do black magic in 
the configuration..


The error really seems to came from 3.8 or 3.9, since i can still reach 
the wiki nominally with my (some being non-updated) machines using 
python 3.7. This didn't evolve since i discovered the problem few days ago.


--lucas


On 24/02/2021 16:20, [email protected] wrote:

On 2021-02-24 at 15:29:58 +0100,
lucas  wrote:


I'm currently trying to understand an error when using the dokuwikixmlrpc
python module, allowing to easily work with DokuWiki RPC interface.

Another description of the problem :
https://github.com/kynan/dokuwikixmlrpc/issues/8

Here is the code, tailored to work with the DokuWiki RPC interface:

 from urllib.parse import urlencode
 import xmlrpc.client as xmlrpclib

 URL = 'wiki.example.net'
 USER = 'user'
 PASSWD = 'password'
 USER_AGENT = 'DokuWikiXMLRPC  1.0  for testing'

 script = '/lib/exe/xmlrpc.php'
 url = URL + script + '?' + urlencode({'u': USER, 'p': PASSWD})
 xmlrpclib.Transport.user_agent = USER_AGENT
 xmlrpclib.SafeTransport.user_agent = USER_AGENT
 proxy = xmlrpclib.ServerProxy(url)

 v = proxy.dokuwiki.getVersion()
 print(v)

When ran with Python 3.7 (a personnal debian server, or a personal windows
computer), i obtain the expected 'Release 2018-04-22a "Greebo"' as ouput.
When ran with Python 3.9 (my personnal, manjaro machine), i obtain the
following stacktrace:

 Traceback (most recent call last):
   File "/home/project/read.py", line 32, in 
 v = proxy.dokuwiki.getVersion()
   File "/usr/lib/python3.9/xmlrpc/client.py", line 1116, in __call__
 return self.__send(self.__name, args)
   File "/usr/lib/python3.9/xmlrpc/client.py", line 1456, in __request
 response = self.__transport.request(
   File "/usr/lib/python3.9/xmlrpc/client.py", line 1160, in request
 return self.single_request(host, handler, request_body, verbose)
   File "/usr/lib/python3.9/xmlrpc/client.py", line 1190, in
single_request
 raise ProtocolError(
 xmlrpc.client.ProtocolError: 


At the risk of stating the obvious, it might actually be an
authentication problem.  In addition to double checking the password:

(1) make sure all of your certificates (under Arch Linux, on which
Manjaro is based), that's the ca-certificates package) are up to date;
and

(2) check with whoever owns the wiki about any other certificates they
require.

After that, all I know about XML RPC is to avoid it.  :-)


I don't have the possibility to test this on python 3.8 specifically, but
since the XML and XMLRPC modules have been updated in 3.8, and since 3.9
doesn't seems to introduce any change for them, i would expect 3.8 to
introduce some change that dokuwikixmlrpc has somehow to take into
consideration.

Can anyone help me with that one ? I don't know anything about RPC and XML,
i don't know what i need to do know to fix dokuwikixmlrpc.

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


Re: XML RPC changes between 3.7 and 3.9 yield 401 http error

2021-02-24 Thread lucas

On 24/02/2021 18:00, Chris Angelico wrote:

On Thu, Feb 25, 2021 at 2:02 AM lucas  wrote:


Hi everyone,

(Sorry for the double-send if any, i'm not sure the first send was
performed, maybe because of bounce errors according to mailman.)


I'm currently trying to understand an error when using the
dokuwikixmlrpc python module, allowing to easily work with DokuWiki RPC
interface.

Another description of the problem :
 https://github.com/kynan/dokuwikixmlrpc/issues/8

Here is the code, tailored to work with the DokuWiki RPC interface:

  from urllib.parse import urlencode
  import xmlrpc.client as xmlrpclib

  URL = 'wiki.example.net'
  USER = 'user'
  PASSWD = 'password'
  USER_AGENT = 'DokuWikiXMLRPC  1.0  for testing'

  script = '/lib/exe/xmlrpc.php'
  url = URL + script + '?' + urlencode({'u': USER, 'p': PASSWD})
  xmlrpclib.Transport.user_agent = USER_AGENT
  xmlrpclib.SafeTransport.user_agent = USER_AGENT
  proxy = xmlrpclib.ServerProxy(url)

  v = proxy.dokuwiki.getVersion()
  print(v)

When ran with Python 3.7 (a personnal debian server, or a personal
windows computer), i obtain the expected 'Release 2018-04-22a "Greebo"'
as ouput.
When ran with Python 3.9 (my personnal, manjaro machine), i obtain the
following stacktrace:

  Traceback (most recent call last):
File "/home/project/read.py", line 32, in 
  v = proxy.dokuwiki.getVersion()
File "/usr/lib/python3.9/xmlrpc/client.py", line 1116, in __call__
  return self.__send(self.__name, args)
File "/usr/lib/python3.9/xmlrpc/client.py", line 1456, in __request
  response = self.__transport.request(
File "/usr/lib/python3.9/xmlrpc/client.py", line 1160, in request
  return self.single_request(host, handler, request_body, verbose)
File "/usr/lib/python3.9/xmlrpc/client.py", line 1190, in
single_request
  raise ProtocolError(
  xmlrpc.client.ProtocolError: 



A properly-formed URL will start with a protocol. I don't know
specifically what changed, but it's looking like something started
rejecting malformed URLs. Try adding "http://"; or "https://"; to your
URL (whichever is appropriate) and see if both versions will accept
it.

ChrisA



I did that, obtaining the following URL

https://wiki.[…]/lib/exe/xmlrpc.php?u=[…]&p=[…]

on my two currently available computer (laptop on 3.9, remote on 3.7), 
and the results is the same.


For information, i'm uploading the same python program to my remote 
server (debian, 3.7), and running it with the same parameters as my 
laptop (manjaro, 3.9). My laptop is getting the 401, my server is 
getting the expected dokuwiki version.


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


Re: XML RPC changes between 3.7 and 3.9 yield 401 http error

2021-02-24 Thread lucas

On 24/02/2021 18:48, Chris Angelico wrote:

On Thu, Feb 25, 2021 at 4:36 AM lucas  wrote:

A properly-formed URL will start with a protocol. I don't know
specifically what changed, but it's looking like something started
rejecting malformed URLs. Try adding "http://"; or "https://"; to your
URL (whichever is appropriate) and see if both versions will accept
it.

ChrisA



I did that, obtaining the following URL

https://wiki.[…]/lib/exe/xmlrpc.php?u=[…]&p=[…]

on my two currently available computer (laptop on 3.9, remote on 3.7),
and the results is the same.

For information, i'm uploading the same python program to my remote
server (debian, 3.7), and running it with the same parameters as my
laptop (manjaro, 3.9). My laptop is getting the 401, my server is
getting the expected dokuwiki version.


(I'm aware that you have some other actual domain, but I'll continue
using "wiki.example.net" as per your original post.)

Is it possible that there's some kind of server-based restriction?
What happens if you call socket.gethostbyname("wiki.example.net") on
both the laptop and the server - do you get back the same IP address?
(Or use gethostbyname_ex, or possibly getaddrinfo if ipv6 support
matters.)

Also, just to make sure there's nothing stupid happening, try printing
out the URL on both machines. Obviously censor the password before
sharing it here, but mainly, make sure that the two are generating the
exact same URL, just in case. Both are running 3.7+, so dict iteration
order shouldn't be getting in your way, but I've seen crazier things
before :)

ChrisA



Thanks for taking time to help me !

I added socket.gethostbyname("wiki.example.net") (i removed the https:// 
since it, obviously now i think about it, led to a socket error)

in the program, so i could verify both the URL and IP are equivalent.

I got the exact same URL and IP. To be sure, i let python run the 
comparison instead of only relying on my eyes.


>>> 'https://wiki.example.net/lib/exe/xmlrpc.php?u=user&p=password' == 
'https://wiki.example.net/lib/exe/xmlrpc.php?u=user&p=password'

True
>>> 'xx.xxx.xxx.197' == 'xx.xxx.xxx.197'
True

You gave me an idea: i checked the nginx log of the server hosting the 
dokuwiki instance, and got something of interest :


[SERVER IP] - - [24/Feb/2021:19:08:31 +0100] "POST 
/lib/exe/xmlrpc.php?u=[USER]&p=[PASSWORD] HTTP/1.1" 200 209 "-" 
"Python-xmlrpc/3.7"
[LAPTOP IP] - - [24/Feb/2021:19:08:35 +0100] "POST /lib/exe/xmlrpc.php 
HTTP/1.1" 401 433 "-" "Python-xmlrpc/3.9"


It seems that the laptop is not sending the arguments, despite them 
being fed in the python code ?



Now i think about it, my remote server host both the python program into 
3.7, and the dokuwiki. One may think it could be the source of the problem.
To prove it's not, i will test with another laptop (the one under 
windows, python 3.7, which successfully accessed the wiki while i was 
discovering the error on my manjaro laptop) as soon as possible.


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


Re: XML RPC changes between 3.7 and 3.9 yield 401 http error

2021-02-24 Thread lucas

On 24/02/2021 19:22, Chris Angelico wrote:

On Thu, Feb 25, 2021 at 5:12 AM lucas  wrote:


On 24/02/2021 18:48, Chris Angelico wrote:
I added socket.gethostbyname("wiki.example.net") (i removed the https://
since it, obviously now i think about it, led to a socket error)
in the program, so i could verify both the URL and IP are equivalent.

I got the exact same URL and IP. To be sure, i let python run the
comparison instead of only relying on my eyes.

  >>> 'https://wiki.example.net/lib/exe/xmlrpc.php?u=user&p=password' ==
'https://wiki.example.net/lib/exe/xmlrpc.php?u=user&p=password'
True
  >>> 'xx.xxx.xxx.197' == 'xx.xxx.xxx.197'
True


Those URLs were printed out from each script, just before attempting the call?


Yes. The program is that one :

import socket
import xmlrpc.client as xmlrpclib
from xml.parsers.expat import ExpatError
from urllib.parse import urlencode

URL = 'https://wiki.example.net'
USER_AGENT = 'DokuWikiXMLRPC  1.0  for testing'

script = '/lib/exe/xmlrpc.php'
url = URL + script + '?' + urlencode({'u': USER, 'p': PASSWD})
print(url)
print(socket.gethostbyname('wiki.example.net'))
# xmlrpclib.Transport.user_agent = USER_AGENT
# xmlrpclib.SafeTransport.user_agent = USER_AGENT

proxy = xmlrpclib.ServerProxy(url)
v = proxy.dokuwiki.getVersion()
print(v)





You gave me an idea: i checked the nginx log of the server hosting the
dokuwiki instance, and got something of interest :

[SERVER IP] - - [24/Feb/2021:19:08:31 +0100] "POST
/lib/exe/xmlrpc.php?u=[USER]&p=[PASSWORD] HTTP/1.1" 200 209 "-"
"Python-xmlrpc/3.7"
[LAPTOP IP] - - [24/Feb/2021:19:08:35 +0100] "POST /lib/exe/xmlrpc.php
HTTP/1.1" 401 433 "-" "Python-xmlrpc/3.9"

It seems that the laptop is not sending the arguments, despite them
being fed in the python code ?


Fascinating! Well, that does at least simplify things somewhat -
instead of "why is this coming back 401", it's "why is this not
sending credentials".


Yes, we are going forward :)






More data is always good.

ChrisA


I tested from the windows computer (Python 3.8, it appears, not 3.7 as i 
thought), and got the following nginx log:


[LAPTOP IP] - - [24/Feb/2021:20:06:42 +0100] "POST 
/lib/exe/xmlrpc.php?u=[user]&p=[password] HTTP/1.1" 200 209 "-" 
"DokuWikiXMLRPC  1.0  for testing windows"


That other laptop also had an ubuntu installed, with python 3.6.9, so i 
ran the program and got the expected output, and the following nginx log:
[LAPTOP IP] - - [24/Feb/2021:20:04:04 +0100] "POST 
/lib/exe/xmlrpc.php?u=[user]&p=[password] HTTP/1.1" 200 209 "-" 
"DokuWikiXMLRPC  1.0  for testing ubuntu"


Both accessed correctly the dokuwiki version. Unless this is a platform 
specific problem, it seems to narrow it to 3.9.


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


Re: XML RPC changes between 3.7 and 3.9 yield 401 http error

2021-02-24 Thread lucas

On 24/02/2021 20:21, Chris Angelico wrote:

On Thu, Feb 25, 2021 at 6:14 AM lucas  wrote:

I tested from the windows computer (Python 3.8, it appears, not 3.7 as i
thought), and got the following nginx log:

[LAPTOP IP] - - [24/Feb/2021:20:06:42 +0100] "POST
/lib/exe/xmlrpc.php?u=[user]&p=[password] HTTP/1.1" 200 209 "-"
"DokuWikiXMLRPC  1.0  for testing windows"

That other laptop also had an ubuntu installed, with python 3.6.9, so i
ran the program and got the expected output, and the following nginx log:
[LAPTOP IP] - - [24/Feb/2021:20:04:04 +0100] "POST
/lib/exe/xmlrpc.php?u=[user]&p=[password] HTTP/1.1" 200 209 "-"
"DokuWikiXMLRPC  1.0  for testing ubuntu"

Both accessed correctly the dokuwiki version. Unless this is a platform
specific problem, it seems to narrow it to 3.9.



Curious.

I think, at this point, we need a repeatable test case. Wonder how
hard it would be to make a single Python script that has a tiny server
and a tiny client, and tries to connect them.

ChrisA


I will work on that tomorrow.

Thanks for your guidance, i will come back with a repeatable test case.

Best regards,
--lucas
--
https://mail.python.org/mailman/listinfo/python-list


Re: XML RPC changes between 3.7 and 3.9 yield 401 http error

2021-03-27 Thread lucas

Following our previous discussion:
https://www.talkend.net/post/287193.html

I finally took time (thanks to Florian R.) to get a reproducible example 
of my problem, as asked previously by ChrisA.


The following code is implementing a webserver with Flask, and a client 
with the XMLRPC client:


import sys
from xmlrpc import server, client
from urllib.parse import urlencode
from flask import Flask, request


PORT = 23456
USER, PASSWD = 'user', 'password'
URL = '127.0.0.1:' + str(PORT)

if len(sys.argv) > 1 and sys.argv[1] == 'server':
app = Flask(__name__)
@app.route('/', methods=['POST'])
@app.route('/RPC2', methods=['POST'])
def login():
print('REQUEST:', request.args)
return 'ok'
app.run(debug=True, host='localhost', port=PORT)

else:
url = 'http://' + URL + '?' + urlencode({'u': USER, 'p': PASSWD})
print(url)
proxy = client.ServerProxy(url)
print(proxy, dir(proxy))
    print(proxy.add(2, 3))


You can run the client with `python3 p.py`, and the server with `python3 
p.py server`.


On debian, Python 3.7, i got:

lucas@debianserver:~$ python3.7 p.py server
 * Serving Flask app "p" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a 
production deployment.

   Use a production WSGI server instead.
 * Debug mode: on
 * Running on http://localhost:23456/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 249-992-288
127.0.0.1 - - [27/Mar/2021 18:31:13] "POST /?u=user&p=password 
HTTP/1.1" 404 -



On Arch, python 3.9, i got:

 aluriak@arch❯ python3.9 p.py server
 * Serving Flask app "p" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a 
production deployment.

   Use a production WSGI server instead.
 * Debug mode: on
 * Running on http://localhost:23456/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 821-276-100
127.0.0.1 - - [27/Mar/2021 18:35:45] "POST /RPC2 HTTP/1.1" 200 -


Both systems return the same output on command `pip3 freeze | grep 
Flask`, which is `Flask==1.1.2`.



Note that the two outputs differs in two ways:

127.0.0.1 - - [27/Mar/2021 18:31:13] "POST /?u=user&p=password 
HTTP/1.1" 404 -

127.0.0.1 - - [27/Mar/2021 18:35:45] "POST /RPC2 HTTP/1.1" 200 -

The first contains the arguments, and the second contains the path. 
Sounds like there is something wrong with both modules.


This should be a reproducible example ; plus i'm not the only one to 
encounter that problem:

https://github.com/kynan/dokuwikixmlrpc/issues/8#issuecomment-808755244

Best regards,
--lucas
--
https://mail.python.org/mailman/listinfo/python-list


Re: XML RPC changes between 3.7 and 3.9 yield 401 http error

2021-03-27 Thread lucas
And, in my outputs, a key part is missing: the received arguments as 
parsed by Flask:


Python 3.7:
REQUEST: ImmutableMultiDict([('u', 'user'), ('p', 'password')])

Python 3.9:
REQUEST: ImmutableMultiDict([])


Have a good day everyone,
--lucas


On 27/03/2021 18:53, lucas wrote:

Following our previous discussion:
     https://www.talkend.net/post/287193.html

I finally took time (thanks to Florian R.) to get a reproducible example 
of my problem, as asked previously by ChrisA.


The following code is implementing a webserver with Flask, and a client 
with the XMLRPC client:


     import sys
     from xmlrpc import server, client
     from urllib.parse import urlencode
     from flask import Flask, request


     PORT = 23456
     USER, PASSWD = 'user', 'password'
     URL = '127.0.0.1:' + str(PORT)

     if len(sys.argv) > 1 and sys.argv[1] == 'server':
     app = Flask(__name__)
     @app.route('/', methods=['POST'])
     @app.route('/RPC2', methods=['POST'])
     def login():
     print('REQUEST:', request.args)
     return 'ok'
     app.run(debug=True, host='localhost', port=PORT)

     else:
     url = 'http://' + URL + '?' + urlencode({'u': USER, 'p': PASSWD})
     print(url)
     proxy = client.ServerProxy(url)
     print(proxy, dir(proxy))
     print(proxy.add(2, 3))


You can run the client with `python3 p.py`, and the server with `python3 
p.py server`.


On debian, Python 3.7, i got:

     lucas@debianserver:~$ python3.7 p.py server
  * Serving Flask app "p" (lazy loading)
  * Environment: production
    WARNING: This is a development server. Do not use it in a 
production deployment.

    Use a production WSGI server instead.
  * Debug mode: on
  * Running on http://localhost:23456/ (Press CTRL+C to quit)
  * Restarting with stat
  * Debugger is active!
  * Debugger PIN: 249-992-288
     127.0.0.1 - - [27/Mar/2021 18:31:13] "POST /?u=user&p=password 
HTTP/1.1" 404 -



On Arch, python 3.9, i got:

  aluriak@arch❯ python3.9 p.py server
  * Serving Flask app "p" (lazy loading)
  * Environment: production
    WARNING: This is a development server. Do not use it in a 
production deployment.

    Use a production WSGI server instead.
  * Debug mode: on
  * Running on http://localhost:23456/ (Press CTRL+C to quit)
  * Restarting with stat
  * Debugger is active!
  * Debugger PIN: 821-276-100
     127.0.0.1 - - [27/Mar/2021 18:35:45] "POST /RPC2 HTTP/1.1" 200 -


Both systems return the same output on command `pip3 freeze | grep 
Flask`, which is `Flask==1.1.2`.



Note that the two outputs differs in two ways:

     127.0.0.1 - - [27/Mar/2021 18:31:13] "POST /?u=user&p=password 
HTTP/1.1" 404 -

     127.0.0.1 - - [27/Mar/2021 18:35:45] "POST /RPC2 HTTP/1.1" 200 -

The first contains the arguments, and the second contains the path. 
Sounds like there is something wrong with both modules.


This should be a reproducible example ; plus i'm not the only one to 
encounter that problem:
 
https://github.com/kynan/dokuwikixmlrpc/issues/8#issuecomment-808755244


Best regards,
--lucas

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


Re: XML RPC changes between 3.7 and 3.9 yield 401 http error

2021-03-27 Thread lucas

Thank you ChrisA !

I hope it will solve it too. Do i need to do anything ?

Thank you for your time and help.

Best wishes,
--lucas



On 27/03/2021 22:49, Chris Angelico wrote:

On Sun, Mar 28, 2021 at 5:00 AM lucas  wrote:

I finally took time (thanks to Florian R.) to get a reproducible example
of my problem, as asked previously by ChrisA.


Thanks! With this in hand, I can play around with it.


On debian, Python 3.7, i got:

  127.0.0.1 - - [27/Mar/2021 18:31:13] "POST /?u=user&p=password
HTTP/1.1" 404 -

On Arch, python 3.9, i got:

   aluriak@arch❯ python3.9 p.py server
  127.0.0.1 - - [27/Mar/2021 18:35:45] "POST /RPC2 HTTP/1.1" 200 -


On Debian, with both versions having been built from source, the same
occurs. Furthermore, Python 3.8 behaves as 3.7 does. This definitely
changed in 3.9.


Note that the two outputs differs in two ways:

  127.0.0.1 - - [27/Mar/2021 18:31:13] "POST /?u=user&p=password
HTTP/1.1" 404 -
  127.0.0.1 - - [27/Mar/2021 18:35:45] "POST /RPC2 HTTP/1.1" 200 -

The first contains the arguments, and the second contains the path.
Sounds like there is something wrong with both modules.


One point of note is that the request as given actually doesn't have a
slash. I think that's technically wrong, but a lot of systems will
just implicitly add the slash. That, coupled with commit 9c4c45, is
why you're seeing "/RPC2" in there. That distinction vanishes if you
change your client thusly:

url = 'http://' + URL + '/?' + urlencode({'u': USER, 'p': PASSWD})

Actually, it looks like all the changes came in with that commit. The
old way used some internal functions from urllib.parse, and the new
way uses the public function urllib.parse.urlparse(), and there are
some subtle differences. For one thing, the old way would implicitly
readd the missing slash, thus hiding the above issue; the new way
leaves the path empty (thus triggering the "/RPC2" replacement). But
perhaps more significantly, the old way left query parameters in the
"path" portion, where the new way has a separate "query" portion that
is being lost. Here's the relevant BPO:

https://bugs.python.org/issue38038

It seems to have been intended as a pure refactor, so I'd call this a
regression. Fortunately, it's not difficult to fix; but I'm not sure
if there are any other subtle changes.

The regression's already been reported so I'm adding to this issue:

https://bugs.python.org/issue43433

Hopefully that solves the problem!

ChrisA


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


argparse support of/by argparse

2021-07-12 Thread lucas

Hello everyone,

Let us consider this patch of code:

import argparse

def parse_cli() -> argparse.Namespace:
parser = argparse.ArgumentParser()
parser.add_argument('n', type=int)
return parser.parse_args()

args = parse_cli()
print(args.n + ' ')  # type error

Running CPython on it will raise a TypeError, and running Mypy on it 
will indicate that no issues were found.


I was wondering if there is any way for me to have mypy detecting the 
args.n type, based on the type keyword of the parser.add_argument function ?


It appears that some type annotations were added to tierce party 
modules, provided by mypy itself. Is there a technical issue preventing 
such work to be made for argparse (or other CLI ; i didn't find anything 
for others either)


Thank you for reading,
--lucas
--
https://mail.python.org/mailman/listinfo/python-list


Re: argparse support of/by argparse

2021-07-13 Thread lucas

Mmmh, that may work just fine !
Thanks for that idea, ChrisA, i'm looking forward to implement that.

Best wishes,
--lucas



On 12/07/2021 21:33, Chris Angelico wrote:

On Tue, Jul 13, 2021 at 5:22 AM lucas  wrote:


Hello everyone,

Let us consider this patch of code:

  import argparse

  def parse_cli() -> argparse.Namespace:
  parser = argparse.ArgumentParser()
  parser.add_argument('n', type=int)
  return parser.parse_args()

  args = parse_cli()
  print(args.n + ' ')  # type error

Running CPython on it will raise a TypeError, and running Mypy on it
will indicate that no issues were found.

I was wondering if there is any way for me to have mypy detecting the
args.n type, based on the type keyword of the parser.add_argument function ?

It appears that some type annotations were added to tierce party
modules, provided by mypy itself. Is there a technical issue preventing
such work to be made for argparse (or other CLI ; i didn't find anything
for others either)



Seems complicated, since it depends on a lot of run-time information.
What if you flip the problem on its head? Instead of creating the
argparser and letting that govern the types, maybe create a dataclass,
and then programmatically build the parser.

from dataclasses import dataclass
import argparse

@dataclass
class Args:
 n: int

def parse_cli() -> Args:
 parser = argparse.ArgumentParser()
 for field, typ in Args.__dataclass_fields__.items():
 if hasattr(typ, "type"): typ = typ.type # Python 3.10 changed
things a bit
 parser.add_argument(field, type=typ)
 return Args(**vars(parser.parse_args()))

args = parse_cli()
print(args.n + ' ')


Only barely tested it and didn't try MyPy, but that's the basic idea.
You'd have to figure out the tidiest way to define all the other
attributes of your arguments (help text, etc), but ideally, all the
info should be able to be coded in the dataclass.

Incidentally, you could choose to make parse_cli into a classmethod of
Args. Might be cleaner.

ChrisA


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


Re: on writing a while loop for rolling two dice

2021-09-02 Thread lucas

def how_many_times():
   x, y = 0, 1
   c = 0
   while x != y:
 c = c + 1
 x, y = roll()
   return c, (x, y)


Since I haven't seen it used in answers yet, here's another option using our 
new walrus operator

def how_many_times():
 roll_count = 1
 while (rolls := roll())[0] != rolls[1]:
 roll_count += 1
 return (roll_count, rolls)



I would go even further, saying there is no need to «roll dices»:

def how_many_times():
nb_times = random.choice([n for n in range(50) for _ in 
range(round(1*(1/6)*(5/6)**(n-1)))])

return nb_times, (random.randint(1, 6),) * 2

If i had more time on my hands, i would do something with bissect to get 
nb_times with more precision, as i have (mis)calculated that the 
probability of having nb_times = N is N = (1/6) * (5/6) ** (N-1)

Something like this may work:

nb_times = [random.random() < (1/6) * (5/6) ** (N-1) for N in 
range(1, 50)].index(True)+1

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


import question

2021-11-18 Thread lucas
hello one and all,

are there any other ways to import a module or package other then the "import" 
or "from...import..." statements?  i ask because i'm allowing programming on my 
web2py website and i don't want any accessing packages like os or sys.

thank you in advance and have a great day, lucas
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: import question

2021-11-19 Thread lucas
ok.  all good advice.  thank you for that.  and with all that I've decided what 
to do.

I'm going to close off any server-side python access so that I don't expose my 
server or the file system to vulnerabilities and/or wonton attacks.  I am 
building a site for education and what I will configure is allow students to 
setup and save their projects on the server but only direct them to program in 
client-side Brython, which is a javascript translation of python for browsers, 
hence "Brython" or "browser python".  my server will provide the javascript 
files for Brython and its standard libraries and any processing of the 
student's projects will be directly on the client-side.  this way there is no 
access to the server or cpu or memory management problems.  the server will 
simply server html and Brython-based text, i.e., static pages, to the client 
browser and the browser will process and interact with the Brython directly.  

overall, the server will stay secure and the students can learn python through 
Brython.  sound, right?  Lucas
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ast.parse, ast.dump, but with comment preservation?

2021-12-16 Thread lucas

Hi !

Maybe RedBaron may help you ?

https://github.com/PyCQA/redbaron

IIRC, it aims to conserve the exact same representation of the source 
code, including comments and empty lines.


--lucas


On 16/12/2021 04:37, [email protected] wrote:

I wrote a little open-source tool to expose internal constructs in OpenAPI. 
Along the way, I added related functionality to:
- Generate/update a function prototype to/from a class
- JSON schema
- Automatically add type annotations to all function arguments, class 
attributes, declarations, and assignments

alongside a bunch of other features. All implemented using just the builtin 
modules (plus astor on Python < 3.9; and optionally black).

Now I'm almost at the point where I can run it—without issue—against, e.g., the 
entire TensorFlow codebase. Unfortunately this is causing huge `diff`s because 
the comments aren't preserved (and there are some whitespace issues… but I 
should be able to resolve the latter).

Is the only viable solution available to rewrite around redbaron | libcst? - I 
don't need to parse the comments just dump them out unedited whence they're 
found…

Thanks for any suggestions

PS: Library is https://github.com/SamuelMarks/cdd-python (might relicense with 
CC0… anyway too early for others to use; wait for the 0.1.0 release ;])

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


How to print a file in binary mode

2006-10-22 Thread Lucas
I need print a file in binary mode .

f = f.open('python.jpg','rb')
bytes = f.read()
f.close()

print(bytes)

I can't get any binary code.

how to do it?

Thank you very much!

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


Re: How to print a file in binary mode

2006-10-22 Thread Lucas
thanks for your answer.

I known how to do it.
read() return a string. so
1) bytes = read(1) #read the file by bit.
2) chrString  = ord(bytes) #convert the string to ASCII.
3) print numberToBinary(chrString) #convert the ASCII to Binary using
my function.
4) Loop

I do it because I want to encrypt a string into a picture using RSA
algorithm.
so I first convert the string to binary,and then saving the binary into
picture

finally, print the picture by binary!

It is my coursework and studying PYTHON passingly : )

Marc 'BlackJack' Rintsch wrote:
> In <[EMAIL PROTECTED]>, Lucas wrote:
>
> > I need print a file in binary mode .
> >
> > f = f.open('python.jpg','rb')
> > bytes = f.read()
> > f.close()
> >
> > print(bytes)
> >
> > I can't get any binary code.
>
> What do you mean by "binary code"?  If you use ``print repr(bytes)``
> everything outside ASCII will be printed as escape sequence.
>
> But why do you want to "print" JPEG images anyway?
> 
> Ciao,
>   Marc 'BlackJack' Rintsch

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


Re: How to print a file in binary mode

2006-10-22 Thread Lucas
well,  if I just open the file in binary mode, and write a string,e.g
'660', how do i read the result? I means I need print the binary in
screen.

do these?

fileWrite = open('a.jpg',''ab')
fileWrite.write('660')
fileWrite.close()

fileRead = open('a.jpg','rb')
b = fileRead.read()
fileRead.close()
print b

???

Thanks again

Fredrik Lundh wrote:
> Lucas wrote:
>
> > I do it because I want to encrypt a string into a picture using RSA
> > algorithm.
>
> what does "into" mean?  are you supposed to encrypt the binary data
> representing the JPEG image, or embed a message into the actual image?
>
>  > so I first convert the string to binary,and then saving the binary
>  > into picture
>
> you seem to have a rather fuzzy understanding of the words "string" and
> "binary" here.  if you read from a file that's opened in binary mode,
> you get an 8-bit string that contains the binary data.  there's no need
> for any conversion here; just use the data you got from "read".
>
>  > finally, print the picture by binary!
>
> do you mean "save the picture to a binary file", or something else?
> 
> 

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


Re: How to print a file in binary mode

2006-10-22 Thread Lucas
I am sorry my english is not good!

strList = ['1010010100','11101000100']

fileWrite = open('a.jpg','ab')
for item in strList:
   fileWrite.write(item)
fileWrite.close()
# I don't know whether or not I succeed

fileRead = open('a.jpg','rb')
b = fileRead.read()
fileRead.close()
print b
#it is wrong
# How can I display a.jpg's binary code?

Lucas wrote:
> well,  if I just open the file in binary mode, and write a string,e.g
> '660', how do i read the result? I means I need print the binary in
> screen.
>
> do these?
>
> fileWrite = open('a.jpg',''ab')
> fileWrite.write('660')
> fileWrite.close()
>
> fileRead = open('a.jpg','rb')
> b = fileRead.read()
> fileRead.close()
> print b
>
> ???
>
> Thanks again
>
> Fredrik Lundh wrote:
> > Lucas wrote:
> >
> > > I do it because I want to encrypt a string into a picture using RSA
> > > algorithm.
> >
> > what does "into" mean?  are you supposed to encrypt the binary data
> > representing the JPEG image, or embed a message into the actual image?
> >
> >  > so I first convert the string to binary,and then saving the binary
> >  > into picture
> >
> > you seem to have a rather fuzzy understanding of the words "string" and
> > "binary" here.  if you read from a file that's opened in binary mode,
> > you get an 8-bit string that contains the binary data.  there's no need
> > for any conversion here; just use the data you got from "read".
> >
> >  > finally, print the picture by binary!
> >
> > do you mean "save the picture to a binary file", or something else?
> > 
> > 

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


How to get each pixel value from a picture file!

2006-10-23 Thread Lucas
I want to change some pixel value in the picture file. how to do it?

If I read the file in binary mode, a bit == a pixel ?

Thanks

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


Re: How to get each pixel value from a picture file!

2006-10-23 Thread Lucas
Thank you for your answer.

I have some new questions:

1)  the value of return from getpixel() is a RGB number?
 print im.getpixel((44,55))   > (160,160,160)

2) I want to put a number into the picture for encryption(replace least
significant bit (LSB) of image intensity with message bit).

If i use putpixel((44,55),0) , the number 0 will be changed RGB
value or others.?

3) pix = im.load()
print pix[44,55]
pix[44, 55] = value
 my python cannt identify "[x,y]" ??

Steve Holden wrote:
> Lucas wrote:
> > I want to change some pixel value in the picture file. how to do it?
> >
> The most popular way is probably the Python Image Library, known to its
> friends as PIL:
>
>http://www.pythonware.com/products/pil/
>
> You will see from
>
>http://www.pythonware.com/library/pil/handbook/image.htm
>
> that images have .getpixel() and .putpixel() methods that will allow you
> to read and set individual pixels if you want. Be aware that the
> forthcoming release will give faster access using something called
> "pixel access objects", about which I know nothing.
>
> > If I read the file in binary mode, a bit == a pixel ?
> >
> Only for monochrome images, of course. Greyscale and color images have
> more bits per pixel, and some formats use a palette mapping to allow
> high color-fidelity with fewer bits per pixel (GIF is one such format).
>
> Download PIL and play with it. I'm sure you'll have a lot of fun, and
> you can do a surprising amount of processing just noodling around in an
> interactive interpreter session.
>
> regards
>   Steve
> --
> Steve Holden   +44 150 684 7255  +1 800 494 3119
> Holden Web LLC/Ltd  http://www.holdenweb.com
> Skype: holdenweb   http://holdenweb.blogspot.com
> Recent Ramblings http://del.icio.us/steve.holden

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


Re: How to get each pixel value from a picture file!

2006-10-23 Thread Lucas
:)

1)I just copy the tutorial to run "print pix[44,55]". I really dont
know why they wrote that?!


2) i think putpixel((44, 55), (0, 0, 0)) and putpixel((44,55),0) is
same.

thank you  again. I think I have solved my problem.

Steve Holden wrote:
> Lucas wrote:
> > Thank you for your answer.
> >
> > I have some new questions:
> >
> > 1)  the value of return from getpixel() is a RGB number?
> >  print im.getpixel((44,55))   > (160,160,160)
> >
> Yes, that's an RGB tuple.
>
> > 2) I want to put a number into the picture for encryption(replace least
> > significant bit (LSB) of image intensity with message bit).
> >
> > If i use putpixel((44,55),0) , the number 0 will be changed RGB
> > value or others.?
> >
> I think you'd need to use
>
>  putpixel((44, 55), (0, 0, 0))
>
> but it's easy enough to try out interactively ...
>
> > 3) pix = im.load()
> > print pix[44,55]
> > pix[44, 55] = value
> >  my python cannt identify "[x,y]" ??
> >
>
> Now what makes you think that an image can be addressed that way? I'd be
> quite surprised if yo got anything other than a TypeError doing that.
>
> regards
>   Steve
> --
> Steve Holden   +44 150 684 7255  +1 800 494 3119
> Holden Web LLC/Ltd  http://www.holdenweb.com
> Skype: holdenweb   http://holdenweb.blogspot.com
> Recent Ramblings http://del.icio.us/steve.holden

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


Re: How to get each pixel value from a picture file!

2006-10-23 Thread Lucas
http://www.pythonware.com/library/pil/handbook/image.htm

im.load() said

Leif K-Brooks wrote:
> Lucas wrote:
> > 1)I just copy the tutorial to run "print pix[44,55]". I really dont
> > know why they wrote that?!
> 
> What tutorial? Where does it say that?

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


lucas ares

2008-01-03 Thread lucas
visitame www.lucasares.com.ar
-- 
http://mail.python.org/mailman/listinfo/python-list


Silly function call lookup stuff?

2005-09-27 Thread Lucas Lemmens
Dear pythonians,

I've been reading/thinking about the famous function call speedup 
trick where you use a function in the local context to represent 
a "remoter" function to speed up the 'function lookup'.

"This is especially usefull in a loop where you call the function a 
zillion time" they say.

I think this is very odd behavior. 

Why isn't the result of the first function-lookup cached so that following
function calls don't need to do the function-lookup at all?

And if the context changes (an import-statement say) reset the
cached 'function-lookups'.

This way any function would only need to be looked up once.

L.








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


Re: Silly function call lookup stuff?

2005-09-27 Thread Lucas Lemmens
On Tue, 27 Sep 2005 22:41:22 +0200, Fredrik Lundh wrote:

> Lucas Lemmens wrote:
> 
>> Why isn't the result of the first function-lookup cached so that
>> following function calls don't need to do the function-lookup at all?
>>
>> And if the context changes (an import-statement say) reset the cached
>> 'function-lookups'.
> 
> import isn't the only way for the "context" to change.  how many other
> ways can you think of ?

So myLocalFunc = hisRemoteFunc may break if you're not carefull you mean.
If not then there's room for improvement.

> 
>> This way any function would only need to be looked up once.
> 
> you haven't really thought this over, have you?
> 
> 

You haven't really answered my questions have you?
L.


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


Re: Silly function call lookup stuff?

2005-09-27 Thread Lucas Lemmens
On Tue, 27 Sep 2005 13:56:53 -0700, Michael Spencer wrote:

> Lucas Lemmens wrote:
>> Dear pythonians,
>> 
>> I've been reading/thinking about the famous function call speedup trick
>> where you use a function in the local context to represent a "remoter"
>> function to speed up the 'function lookup'.
>> 
>> "This is especially usefull in a loop where you call the function a
>> zillion time" they say.
>> 
>> I think this is very odd behavior.
>> 
>> Why isn't the result of the first function-lookup cached so that
>> following function calls don't need to do the function-lookup at all?
>> 
> I guess because the function name may be re-bound between loop iterations.
>  Are there good applications of this?  I don't know.

Yuk I'd hate that. I think it would be extremely rare.

Would the myLocalFunc = hisRemoteFunc optimization break in such a case?

If not then why not auto-add a local hisRemoteFunc that points to the
remote hisRemoteFunc to the local context when hisRemoteFunc
is executed for the first time.

> 
>> And if the context changes (an import-statement say) reset the cached
>> 'function-lookups'.
> 
> In general an object doesn't know what names are bound to it and there are
> many ways besides an import statement of binding/re-binding, so "if the
> context changes" is easier said than done.
> 

My guess (but I'm not a python programmer) is that context changes would
be the odd case.

So optimizing for not having them ...

> 
>> This way any function would only need to be looked up once.
>> 
>> L.
>> 
> Would you apply this optimization to all lookups in outer scopes, or just
> callables?  Why? ;-)

Hmmm callables have probably the highest chance of being recalled.

> 
> Michael

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


Re: Pythonwin crashes

2005-09-28 Thread Lucas Raab
accolades wrote:
> Does anyone else have a problem with Pythonwin crashing after running a
> python script with graphics libraries? Whenever I use Pythonwin to run
> a PyGame or PyOgre script, Pythonwin crashes when the script exits.
> 
> I know it's probably because the Pythonwin interpreter can't read from
> the console once the graphics mode has been changed, but has anyone
> discovered a workaround? I'd like to know if this problem is specific
> to my machine, or if others have witnessed this.
> 
> Thanks
> Tim
> 

I think it's pretty much universal. Pythonwin crashes when you run 
programs with Tk in them.

-- 
--
Lucas Raab
lvraab"@"earthlink.net
dotpyFE"@"gmail.com
AIM:Phoenix11890
MSN:dotpyfe "@" gmail.com
IRC:lvraab
ICQ:324767918
Yahoo:  Phoenix11890
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: A Moronicity of Guido van Rossum

2005-10-02 Thread Lucas Raab
Xah Lee wrote:

[snip]

>(they tried, with their limited implementation of lambda and
> shun it like a plaque)

Can't say I've heard that expression before...

-- 
------
Lucas Raab
lvraab"@"earthlink.net
dotpyFE"@"gmail.com
AIM:Phoenix11890
MSN:dotpyfe "@" gmail.com
IRC:lvraab
ICQ:324767918
Yahoo:  Phoenix11890
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Perl-Python-a-Day: Sorting

2005-10-18 Thread Lucas Raab
[snip]

> Thanks. I didn't know there's also a sort function in Python (2.4),
> besides the method. (i've mentioned your name as acknowledgement at my
> website essay)

[snip]

With his permission, of course...

-- 
------
Lucas Raab
lvraab"@"earthlink.net
dotpyFE"@"gmail.com
AIM:Phoenix11890
MSN:dotpyfe "@" gmail.com
IRC:lvraab
ICQ:324767918
Yahoo:  Phoenix11890
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python Operating System???

2005-01-06 Thread Lucas Raab
David Brown wrote:
Hello. I recently came across a free operating system called Unununium (or
something like that) and it was developed in Python and Assembly.
Now, I have been looking for a way to make an operating system for a long
long time and the only possibilities I could find were C++ and assembly. I
don't mind assembly so much if I don't have to use it very often. But C++ is
so complicated and errors are pretty much impossible to find in the code for
me.
So, I was wondering if it would be possible to find a bootloader that loads
a python file at startup or something...
Is there an example somewhere of a Python OS?
Thanks!

Hasn't there been numerous discussions about this in the past??
--
http://mail.python.org/mailman/listinfo/python-list


Re: Old Paranoia Game in Python

2005-01-09 Thread Lucas Raab
Sean P. Kane wrote:
I ported the old (and long since removed) game from the bsd-game pacakge 
called, Paranoia, based on the old Paranoia role playing game from C to 
Python as a simple exercise in learning the language and pure late night 
boredom. Anyways, here it is for anyone looking for a few minutes of 
nostalgia. I may get around to posting this at 
http://homepage.mac.com/spkane/ or http://www.spkane.org/, but for now 
here it is. Improvements or corrections, welcome.

Thanks,
Sean

Equipment: Red Reflec Armour, Laser Pistol, Laser Barrel (red),
  Notebook & Stylus, Knife, Com Unit 1, Jump suit,
  Secret Illuminati Eye-In-The-Pyramid(tm) Decoder ring,
  Utility Belt & Pouches
=== 

The Illuminati really have infiltrated our society.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Old Paranoia Game in Python

2005-01-09 Thread Lucas Raab
Aahz wrote:
In article <[EMAIL PROTECTED]>,
Lucas Raab  <[EMAIL PROTECTED]> wrote:
Sean P. Kane wrote:
I ported the old (and long since removed) game from the bsd-game pacakge 
called, Paranoia, based on the old Paranoia role playing game from C to 
Python as a simple exercise in learning the language and pure late night 
boredom. Anyways, here it is for anyone looking for a few minutes of 
nostalgia. I may get around to posting this at 
http://homepage.mac.com/spkane/ or http://www.spkane.org/, but for now 
here it is. Improvements or corrections, welcome.

Equipment: Red Reflec Armour, Laser Pistol, Laser Barrel (red),
 Notebook & Stylus, Knife, Com Unit 1, Jump suit,
 Secret Illuminati Eye-In-The-Pyramid(tm) Decoder ring,
 Utility Belt & Pouches
=== 

The Illuminati really have infiltrated our society.

Stay alert!
Trust no one!
Keep your laser handy!
Well, I really meant "Secret Illuminati Eye-In-The-Pyramid(tm) Decoder 
ring", but if you wanted to go in another direction...
--
http://mail.python.org/mailman/listinfo/python-list


Re: Old Paranoia Game in Python

2005-01-10 Thread Lucas Raab
[EMAIL PROTECTED] wrote:
Aahz wrote:
Trust the computer, the computer is your friend.

However, the computer isn't a fuckin' mind reader.
If you're going to post source code on the usenet, don't
have lines longer than 72 characters. Otherwise you'll
find your code has wrapped lines. This not only causes
syntax errors in your choose and print statements but
also fucks up the formatting of of printed paragraphs.
Stupid human.
Temper, temper...
--
http://mail.python.org/mailman/listinfo/python-list


Re: Game programming in Python

2005-01-11 Thread Lucas Raab
Baza wrote:
I'm looking for any books or on-line resources on game programming using
Python. Does anyone have any advice?
--  
Computer says, 'no'


www.panda3d.com, www.pygame.org, www.blender3d.com ...
--
http://mail.python.org/mailman/listinfo/python-list


Re: Game programming in Python

2005-01-11 Thread Lucas Raab
Mike C. Fletcher wrote:
Lucas Raab wrote:
Baza wrote:
I'm looking for any books or on-line resources on game programming using
Python. Does anyone have any advice?
--  Computer says, 'no'

www.panda3d.com, www.pygame.org, www.blender3d.com ...

http://www.vrplumber.com/py3d.py?category=game
HTH,
Mike

 Mike C. Fletcher
 Designer, VR Plumber, Coder
 http://www.vrplumber.com
 http://blog.vrplumber.com
My apologies. :)
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python setup question

2005-01-11 Thread Lucas Raab
Robert Lin wrote:
Hi, 

Sorry for this newbie question, I was wondering if anyone knows why when I run the test, the 
"test_anydbm" test will seg fault and the tests "test_aepack" and "test_al" are 
skipped?
Thanks in advance.
__
 
Robert Lin 
Eng. Intern | Blue Jungle | Redwood City, CA
[EMAIL PROTECTED]
You might not have the right libraries to run those tests.
--
http://mail.python.org/mailman/listinfo/python-list


[OT] SciTe

2005-01-11 Thread Lucas Raab
I didn't want to go through the rigamole of adding myself to the SciTe 
mailing list, so I'm asking my question here. How do I choose a 
different C/C++ compiler to compile in?? I don't use the g++ compiler; I 
use the VC 7 compiler.

TIA,
Lucas
--
http://mail.python.org/mailman/listinfo/python-list


Re: [OT] SciTe

2005-01-12 Thread Lucas Raab
Fouff wrote:
I use Scintilla which is Scite with a lot of configurations files.
In directory exists a file "cpp.properties" and near the end of the file 
is describe the command line use to compile, to link, ...

I think you would be able to change here the compiler.
regards
Fouff
Thanks.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python.org, Website of Satan

2005-01-13 Thread Lucas Raab
Jane wrote:
<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
python.org = 194.109.137.226
194 + 109 + 137 + 226 = 666
What is this website with such a demonic name and IP address?  What
evils are the programmers who use this language up to?
Some people have too much time on their hands...
Jane

Better get some ointment for that burn!!
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python.org, Website of Satan

2005-01-13 Thread Lucas Raab
Arich Chanachai wrote:
Jane wrote:
"Lucas Raab" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
 

Jane wrote:
  

<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]


python.org = 194.109.137.226
194 + 109 + 137 + 226 = 666
What is this website with such a demonic name and IP address?  What
evils are the programmers who use this language up to?
  
Some people have too much time on their hands...
Jane

Better get some ointment for that burn!!
  

Huh???
Jane
 

You said that people have too much "time" on their "hands", so he 
suggested ointment to prevent the irritation etc...  He was probably 
also getting at the topic of this thread (hint: Satan = Hell = Fire), so 
the ointment puts out the burn.
Have fun folks!

- Arich
I'd also like to add that the term "burn" means to be made look stupid 
or be insulted.
--
http://mail.python.org/mailman/listinfo/python-list


porting C code

2005-01-13 Thread Lucas Raab
I am currently in the process of porting some C code into Python and am 
stuck. I don't claim to be the greatest C/C++ programmer; in fact, my 
skills at C are rudimentary at best. My question is I have the 
statement: "typedef   unsigned long int  word32" and later on: "word32 
b[3]" referencing the third bit of the integer. How do I do the same in 
Python?? If this is a stupid, I apologize. It's amazing what the lack of 
sleep does to the brain.

TIA,
Lucas
--
http://mail.python.org/mailman/listinfo/python-list


Re: porting C code

2005-01-14 Thread Lucas Raab
Peter Hansen wrote:
Lucas Raab wrote:
I have the statement: "typedef   unsigned long int  word32" and later 
on: "word32 b[3]" referencing the third bit of the integer. 

If that's really exactly what you have, then you actually have
something defining an array of three unsigned long integers
named "b".  And even if you didn't have precisely "word32 b[3]",
but merely a "b[3]" reference somewhere, it would be referencing
the third element of an array called "b", which is possibly a byte,
maybe a long, but definitely not a bit.
Maybe showing it as code rather than inline in your text
would avoid the possibility of confusion.
-Peter
Sorry, the third "byte" is what I meant. As for code samples, I hope the 
following will work:

typedef   unsigned long int  word32 ;
void mu(word32 *a)
{
int i ;
word32 b[3] ;
b[0] = b[1] = b[2] = 0 ;
for( i=0 ; i<32 ; i++ )
   {
   b[0] <<= 1 ; b[1] <<= 1 ; b[2] <<= 1 ;
   if(a[0]&1) b[2] |= 1 ;
   if(a[1]&1) b[1] |= 1 ;
   if(a[2]&1) b[0] |= 1 ;
   a[0] >>= 1 ; a[1] >>= 1 ; a[2] >>= 1 ;
   }
a[0] = b[0] ;  a[1] = b[1] ;  a[2] = b[2] ;
}
The "a[#]" and "b[#]" are the parts that are giving me trouble.
--
http://mail.python.org/mailman/listinfo/python-list


Re: porting C code

2005-01-15 Thread Lucas Raab
Peter Hansen wrote:
Lucas Raab wrote:
Sorry, the third "byte" is what I meant. 

Fair enough.  Note, however, that as someone pointed out,
it's actually the *fourth* of something, and it would not
necessarily be a byte.  In fact, in your case, it's not:
typedef   unsigned long int  word32 ;
void mu(word32 *a)
{
int i ;
word32 b[3] ;

This defines an array of *3* long (32-bit) integers.
b[0] = b[1] = b[2] = 0 ;

Each of these is just indexing into that array, starting
as Python does with an index origin of zero.
The "a[#]" and "b[#]" are the parts that are giving me trouble.

Between the clarifications you've got and Duncan's post,
you shouldn't have much more trouble now. :-)
-Peter
Thanks.
--
http://mail.python.org/mailman/listinfo/python-list


List problems in C code ported to Python

2005-01-16 Thread Lucas Raab
I'm done porting the C code, but now when running the script I 
continually run into problems with lists. I tried appending and 
extending the lists, but with no avail. Any help is much appreciated 
Please see both the Python and C code at 
http://home.earthlink.net/~lvraab. The two files are ENIGMA.C and engima.py

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


Re: List problems in C code ported to Python

2005-01-16 Thread Lucas Raab
Grant Edwards wrote:
On 2005-01-16, Lucas Raab <[EMAIL PROTECTED]> wrote:
I'm done porting the C code, but now when running the script I 
continually run into problems with lists. I tried appending and 
extending the lists, but with no avail. Any help is much appreciated 
Please see both the Python and C code at 
http://home.earthlink.net/~lvraab. The two files are ENIGMA.C and engima.py

  http://www.catb.org/~esr/faqs/smart-questions.html
I didn't expect to get bitched out just because I didn't follow "protocol."
--
http://mail.python.org/mailman/listinfo/python-list


Re: List problems in C code ported to Python

2005-01-17 Thread Lucas Raab
Grant Edwards wrote:
On 2005-01-16, Lucas Raab <[EMAIL PROTECTED]> wrote:

Please see both the Python and C code at 
http://home.earthlink.net/~lvraab. The two files are ENIGMA.C
and engima.py
 http://www.catb.org/~esr/faqs/smart-questions.html
I didn't expect to get bitched out just because I didn't
follow "protocol."

You didn't get "bitched out".  You did get some very sound
advice. You want help solving a problem, and there are ways you
can greatly increase the chances that you'll get help with your
problem.  After being told the best ways to get help, you
whined about it rather than following it.
Nobody owes you anything. 

Remember that.
[You're darned lucky somebody did take the time to go to your
web site and proof your code for you after your posting said in
effect "I'm too lazy to compose and post a precise question, so
go look at my program and fix it for me."]
Now, go back and read the smart questions reference.
Sorry about that. I had a bad day. First there was the migraine and then 
the fight with my significant other, so yesterday was not a good day. I 
apologize for what I said.
--
http://mail.python.org/mailman/listinfo/python-list


Re: List problems in C code ported to Python

2005-01-17 Thread Lucas Raab
Lucas Raab wrote:
I'm done porting the C code, but now when running the script I 
continually run into problems with lists. I tried appending and 
extending the lists, but with no avail. Any help is much appreciated 
Please see both the Python and C code at 
http://home.earthlink.net/~lvraab. The two files are ENIGMA.C and engima.py

TIA
OK, here's the Python code and the corresponding C code:
def init_mach():
import string
#setup rotor data
i=1
j=0
for j in j<26, j+1:
data[4],[j] = (ref_rotor[j] - 'A'+26) % 26

for i in i<4, i+1:
step[i-1] = step_data[order[i-1]]
for j in j<26, j+1:
data[i],[j] = (rotor[order[i-1]],[j]-'A'+26)%26
data[8-i],[data[i],[j]] = j
void
init_mach( void )
{
  int i, j;
  int ds;
  int u, v;
  /* setup rotor data */
  for (j=0;j<26;j++)
data[4][j] = ((int)ref_rotor[j]-'A'+26)%26;
  for (i=1;i<4;i++)
{
  step[i-1] = step_data[order[i-1]];
  for (j=0;j<26;j++)
{
  data[i][j] = ((int)(rotor[order[i-1]][j])-'A' + 26) % 26;
  data[8-i][data[i][j]] = j;
}
}
Now, do I need to start boning up on lists and how to use them or am I 
missing the bigger picture?? Again, for the complete code see 
http://home.earthlink.net/~lvraab. I'm not asking you to do it for me, 
just some pointers on going about this.
--
http://mail.python.org/mailman/listinfo/python-list


Re: how to write a tutorial

2005-01-23 Thread Lucas Raab
Daniel Bickett wrote:
Most texts in computing are written by authors to defend and showcase
their existence against their peers.

When you aren't busy `showcasing' your ignorance, this is *all* i see
in everything you write.

Um, maybe that was his point...
--
http://mail.python.org/mailman/listinfo/python-list


Re: What's so funny? WAS Re: rotor replacement

2005-01-27 Thread Lucas Raab

As long as we are discussing cryptography, what's wrong with m2crypto?
http://sandbox.rulemaker.net/ngps/m2/ 

Why not incorporate it into the standard distribution?
Or, what about Andrew Kuchling's crypto toolkit?
http://www.amk.ca/python/code/crypto.html

Umm, is it just me or did we just discuss the legal issues of that??
--
http://mail.python.org/mailman/listinfo/python-list


Re: Suggesion for an undergrad final year project in Python

2005-02-01 Thread Lucas Raab
Paul Robson wrote:
On Tue, 01 Feb 2005 12:11:47 +, Kartic wrote:

Sridhar said the following on 2/1/2005 2:11 AM:
Hi,
I am doing my undergrade CS course.  I am in the final year, and would
like to do my project involving Python.  Our instructors require the
project to have novel ideas.  Can the c.l.p people shed light on this
topic?
You try and implement some CS concepts you have learnt using Python. For 
example, if you had a course on parsing and compiler design, try to 
implement a simple language in Python.

Could I suggest going for an area that particularly interests you ; rather
than saying "what sort of project " come up with an area of interest -
this'll mean you probably have more knowledge and will put in more
effort - and then ask for ideas - ideally about something that is missing.
Exactly. If you have an interest in mathematics, then look into 
Numarray. Graphics: Panda3d, Blender, pygame... The list goes on. Feel 
free to append.
--
http://mail.python.org/mailman/listinfo/python-list


Re: VBR mp3 length

2005-07-06 Thread Lucas Raab
No One wrote:
> Hello all,
> If this isn't the correct newsgroup, please redirect me.
> 
> I'm trying to extract the song length from variable bit rate mp3's.
> Does anyone know of a library or bit of code that will do this?  I've
> tried pymad, but it seems to grab the bitrate of the first frame and
> then apply that to the the file length to come up with a total length.
> Needless to say, if the bitrate of the first frame isn't close to the
> overall average, it's wildly off.
> 
> Thanks,
> -Steve

Take a look at http://pymedia.org.

-- 
--
Lucas Raab
lvraab"@"earthlink.net
dotpyFE"@"gmail.com
AIM:Phoenix11890
MSN:dotpyfe "@" gmail.com
IRC:lvraab
ICQ:324767918
Yahoo:  Phoenix11890
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: a new Python Podcast series (and the use of Python in creating podcasting tools)

2005-07-11 Thread Lucas Raab
[EMAIL PROTECTED] wrote:
> Python411 is a series of podcasts about Python, aimed at hobbyists and
> others who are learning Python. Each episode focuses on one aspect of
> learning Python, or one kind of Python programming, and points to
> online tools and tutorials. Python related news and events will also be
> reported upon.
> 
> This podcast series will probably not be of much interest to expert or
> professional programmers. I am a hobbyist and am not qualified nor
> capable of creating a podcast series for accomplished programmers.
> Maybe someone else will do that.
> 
> The four podcasts so far are titled as such:
> 
> Introduction to Python
> 
> Computer Programming for Everybody
> 
> GUI toolkits for Python
> 
> Python for Mobile Devices
> 
> New podcasts will appear from time to time.
> 
> Interestingly, while on the subject of podcasts, I would like to point
> out that Python is emerging as the programming language of choice for
> creating tools for creating podcasts and using podcasts. For instance,
> iPodder is the leading podcast aggregator, or podcatcher, and is
> written in Python. Also, a new program called Podcatcher on a Stick is
> an open source Python project that is creating a podcatcher that runs
> on a  mobile mp3 player itself, rather than on a PC. Links to these
> programs can be found on my web site.
> 
> The home page for Python411 is
> http://www.awaretek.com/python/index.html and one can click on the
> podcasts there to play them, or better you can subscribe to an rss feed
> at http://www.awaretek.com/python/index.xml
> 

Nice idea!! It would be great to get some of the advanced Python guys in 
on this from time to time.

-- 
--
Lucas Raab
lvraab"@"earthlink.net
dotpyFE"@"gmail.com
AIM:Phoenix11890
MSN:dotpyfe "@" gmail.com
IRC:lvraab
ICQ:324767918
Yahoo:  Phoenix11890
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Defending Python

2005-07-11 Thread Lucas Raab
Peter Hansen wrote:
> Jorey Bump wrote:
> 
>> Bruno Desthuilliers <[EMAIL PROTECTED]> wrote:
>>
>>> it's.
>>
>>
>> +1 for this becoming the official name of Python 3000. ;)
>>
>> And now for something completely different...
>>
>> The larch!
> 
> 
> Sorry, already taken:
> 
> '''Larch - John Guttag and Jim Horning <[EMAIL PROTECTED]>. The Larch 
> Project develops aids for formal specifications. Each Larch 
> specification has two components: an interface containing predicates 
> written in the LIL (Larch Interface Language) designed for the target 
> language and a 'trait' containing assertions about the predicates 
> written in LSL, the Larch Shared Language common to all. "The Larch 
> Family of Specification Languages", J. Guttag et al, IEEE Trans Soft Eng 
> 2(5):24-365 (Sep 1985). "Larch: Languages and Tools for Formal 
> Specification", Guttag and Horning, Springer 1993.'''
> 
> Maybe "Ni!"?
> 
> -Peter

Lumberjack??

-- 
--
Lucas Raab
lvraab"@"earthlink.net
dotpyFE"@"gmail.com
AIM:Phoenix11890
MSN:dotpyfe "@" gmail.com
IRC:lvraab
ICQ:324767918
Yahoo:  Phoenix11890
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Documentation bug: Python console behaviour changed

2005-07-19 Thread Lucas Raab
Peter Hansen wrote:
> Kay Schluehr wrote:
> 
>> The documentation of the Python console behaviour is not correct
>> anymore for Python 2.4.1. At least for the Win2K system I'm working on
>> 'Ctrl-Z' does not shut down the console but 'Ctrl-D' etc.
>>
>> The Python interpreter tells me instead:
>>
>>
>>>>> quit
>>
>>
>> 'Use Ctrl-Z plus Return to exit.'
>>
>> Nah, 'Ctrl-Z' is now undo :-)
> 
> 
> Are you really using the console, started with the "Command Prompt" icon 
> from the Start Menu (or some equivalent)?  And are you sure you haven't 
> installed something else that magically changed the behaviour of Ctrl-Z?
> 
> (I get the documented behaviour with Python 2.4.1, under Win XP.)
> 
> -Peter

I'm getting the same behavior as Kay.

-- 
--
Lucas Raab
lvraab"@"earthlink.net
dotpyFE"@"gmail.com
AIM:Phoenix11890
MSN:dotpyfe "@" gmail.com
IRC:lvraab
ICQ:324767918
Yahoo:  Phoenix11890
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python2.4/site-packages

2005-08-11 Thread Lucas Raab
Michael Hoffman wrote:
> Srinivasan TK wrote:
> 
>> Now ,Is it mandatory that I build the third-party
>> packages ( python2.4/site-packages) .
> 
> 
> Only if you want to use them. Really, no.
> 
>> If so is there a
>> list that needs to be built and installed .
> 
> 
> There is a list of them packages which you MAY install but may also 
> choose not to here:
> 
> http://www.python.org/pypi
> 
> This used to be called the Python Package index but is now the Python 
> Cheese Shop? Huh???

You've never heard the Cheese Shop Sketch by Monty Python??

-- 
--
Lucas Raab
lvraab"@"earthlink.net
dotpyFE"@"gmail.com
AIM:Phoenix11890
MSN:dotpyfe "@" gmail.com
IRC:lvraab
ICQ:324767918
Yahoo:  Phoenix11890
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: can I delete one of *.py *.pyc *.pyo in /usr/lib/python2.3 ?

2005-08-20 Thread Lucas Raab
Miernik wrote:
> On my Debian GNU/Linux system I have Python 2.3 installed in
> /usr/lib/python2.3/ where most Python system files like 
> 
> /usr/lib/python2.3/gzip.py
> /usr/lib/python2.3/gzip.pyc
> /usr/lib/python2.3/gzip.pyo
> 
> live, besides of course /usr/bin/python2.3
> 
> I noticed that all those files come in three "flavours":
> *.py *.pyc *.pyo
> 
> Is it possible that only one "flavour" of these files is needed, and I can
> delete the remaining two, any my Python installation will still work?
> 
> The whole /usr/lib/python2.3/ directory takes up over 15 MB, deleting
> two "flavours" would save about 10 MB on my system, and that would help
> me much as I am trying to fit my system on a 256 MB SD card, to make it
> quiet (hard disks are noisy).
> 
> Can I just do 
> cd /usr/lib/python2.3/ && rm -rf *.py && rm -rf *.pyc 
> for example, and everything will still work as before?
> 

You can delete any two of the three and you shouldn't run into any 
problems. However, the .py files are the source code and .pyc and .pyo 
are compiled Python files. The .pyc and .pyo files will load faster 
because they are compiled. Also, if you keep the .py files and then 
execute them, .pyc files will be generated. In short, I would keep the 
.pyc files and delete the others.

-- 
--
Lucas Raab
lvraab"@"earthlink.net
dotpyFE"@"gmail.com
AIM:Phoenix11890
MSN:dotpyfe "@" gmail.com
IRC:lvraab
ICQ:324767918
Yahoo:  Phoenix11890
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: network programming

2005-08-21 Thread Lucas Raab
John Walton wrote:
> Hello, everyone.  I just began school, and they
> already assigned us science fair.  Since I'm in 8th
> grade, I get to do demonstrations for our projects. 
> I'm probably going to demonstrate Python's networking
> capabilities by writing a simple instant messenger
> program.  I only have a few problems:
> 
> 1. I know squat about Python network Programming
> 
> 2. I know nothing about networks
> 
>   So if any of you know of a good Python Networking
> Tutorial or a website with lots of information on
> networks and networking, please reply.  Thanks!
> 

I believe the Twisted Matrix library has an IM module written for it and 
a tutorial on programming with the library. www.twistedmatrix.com


-- 
--
Lucas Raab
lvraab"@"earthlink.net
dotpyFE"@"gmail.com
AIM:Phoenix11890
MSN:dotpyfe "@" gmail.com
IRC:lvraab
ICQ:324767918
Yahoo:  Phoenix11890
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is there any module to play mp3 or wav format files?

2005-08-27 Thread Lucas Raab
el chupacabra wrote:
> Is there any module to play mp3 or wav format files?
> 
> any sample code available somewhere?
> 
> thanks,
> el chupacabra
> 
> 
> --=  Posted using GrabIt  =
> --=  Binary Usenet downloading made easy =-
> -=  Get GrabIt for free from http://www.shemes.com/  =-
> 

http://pymedia.org

-- 
--
Lucas Raab
lvraab"@"earthlink.net
dotpyFE"@"gmail.com
AIM:Phoenix11890
MSN:dotpyfe "@" gmail.com
IRC:lvraab
ICQ:324767918
Yahoo:  Phoenix11890
-- 
http://mail.python.org/mailman/listinfo/python-list


Python game coding

2005-09-17 Thread Lucas Raab
Saw this on Slashdot 
(http://developers.slashdot.org/article.pl?sid=05/09/17/182207&from=rss) 
and thought some people might be interested in it. Direct link to the 
article is 
http://harkal.sylphis3d.com/2005/08/10/multithreaded-game-scripting-with-stackless-python/

-- 
------
Lucas Raab
lvraab"@"earthlink.net
dotpyFE"@"gmail.com
AIM:Phoenix11890
MSN:dotpyfe "@" gmail.com
IRC:lvraab
ICQ:324767918
Yahoo:  Phoenix11890
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Getting tired with py2exe

2005-09-21 Thread Lucas Raab
Scott David Daniels wrote:
> Steve Holden wrote:
> 
>> Thomas Heller wrote:
>>
>>> I'm slowly getting tired maintaining py2exe.  It is far from perfect,
>>> although it has interesting features (I would say).
> 
> 
>> Ignoring all the philosophical questions I'd like to thank you for all 
>> your hard work on py2exe over the years, which has benefited the 
>> Windows Python community immeasurably.
> 
> 
> I second this.
> 
> --Scott David Daniels
> [EMAIL PROTECTED]

*motion passed for entry into Python Hall of Fame*

-- 
--
Lucas Raab
lvraab"@"earthlink.net
dotpyFE"@"gmail.com
AIM:Phoenix11890
MSN:dotpyfe "@" gmail.com
IRC:lvraab
ICQ:324767918
Yahoo:  Phoenix11890
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: AES crypto in pure Python?

2005-02-13 Thread Lucas Raab
[EMAIL PROTECTED] wrote:
I'm looking for an implementation of AES (the Advanced Encryption
Standard) in pure Python.  I'm aware of pycrypto, but that uses C code.
 I'm hoping to find something that only uses Python...I'm willing to
trade speed for portability, since my application is designed for
several different platforms.
Anyone know if this has been done?
Thanks,
-AF
Google
--
http://mail.python.org/mailman/listinfo/python-list


Re: [newbie]How to install python under DOS and is there any Wxpython can be installed under dos?

2005-02-17 Thread Lucas Raab
Leif B. Kristensen wrote:
john san skrev:

Actually the "windows" running very good under the xbox-NTOS via
xboxmediacenter. its just limited functions(not easy to programming
the "windows" prog.), if we can find WxPython-like can be ported (I
can import *
from it  to my xboxPython) )it will be a great great . You
will have HD screen and web surfing on HDTV and computing on HDTV.
think about it! That is a real thing the python-like lang. should to
do otherwise just a garbage(toy).

You can run Linux with MythTV on an XBox. Does all the things you want,
and of course it will run WxPython.
But does that involve modding the Xbox?? As in messing with the hardware??
--
http://mail.python.org/mailman/listinfo/python-list


weird strings question

2005-02-25 Thread Lucas Raab
Is it possible to assign a string a numerical value?? For example, in 
the string "test" can I assign a number to each letter as in "t" = 45, 
"e" =  89, "s" = 54, and so on and so forth??

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


Re: weird strings question

2005-02-26 Thread Lucas Raab
Robert Kern wrote:
Lucas Raab wrote:
Is it possible to assign a string a numerical value?? For example, in 
the string "test" can I assign a number to each letter as in "t" = 45, 
"e" =  89, "s" = 54, and so on and so forth??

Use a dictionary with the strings as keys.
string2num = {}
string2num['t'] = 45
string2num['e'] = 89
etc.
Thanks. That's what I was looking for, but was just unsure exactly how 
to proceed.
--
http://mail.python.org/mailman/listinfo/python-list



Re: Python interfacing with other languages

2005-02-28 Thread Lucas Raab
wuhy80 wrote:
Sure It can work with VB.
you could use the python's com to work with VB.
Take a look at Mark Hammond's Win32 suite of modules. 
http://starship.python.net/crew/mhammond/
--
http://mail.python.org/mailman/listinfo/python-list


Re: intigrate the PyGame module with my Python

2005-03-05 Thread Lucas Raab
[EMAIL PROTECTED] wrote:
I want to intigrate the PyGame module with my Python exe,
means i DONT want to generate .PYD files separtely rather than that
want to put PyGame "c" src with Python workspace of VC project
workspace.
I am unable to import the sub modules( display, rect etc) of pygame,
its raising errors,
am giving the steps i followed, plz help me in this case
I am stuck at the "pygame" embedding using microsoft visual c++ under
win2000 os.
Formarly I have done following activities :
1. Downloaded the windows binary for python 1.5.2 from python.org.
2. Downloaded the sdl windows binary package from pysdl.org.
3. successfully integrated the sdl library into the python15 project.
   A sample py script was tested successfully.
4. Downloaded pygame 1.6 source from pygame.org.
5. Integrated the code into vc project.
6. On similar lines to sdl, the necessary changes were done
   ( as pygame happens to be successor to sdl).
   Initially, the pygame module was not being recognized by the
environment.
 
 
Regards,
 
Devendra

You don't want to put the Pygame files in the pythonxy.exe (where xy is 
your version number) file, but rather the pythonxy.dll file.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Win32 drive mapping... aka "net use"

2005-03-05 Thread Lucas Machado

Alex Martelli wrote:

> import win32net
> win32net.NetUseAdd(None,1,{'remote':r'\\server\share','local':'K:'})
>
> is an example (not all that easy to fathom from the docs, but I
> found it out with a little help from the docs, a little from MSDN,
> and a little experimentation).

I looked through the MSDN and was not able to find much information on
how to properly use the NetUseAdd function.  I searched for the
function and looked through the results but all it showed was some data
structure, but i was actually looking for a list of all possible
arguments and which arguments were/were not required.

my problem with the above NetUseAdd example is that I would rather not
have to specify a device.  In the script I am writing the user may
choose to map multiple shares so I need to be able to map to the next
available device:

net use * \\some_server\share_name

instead of:

net use k: \\server\share

Thanks for the help in advance.  Also, if anyone could provide a link
to good windows api docs for python that would be great.

Cheers,
--Lucas Machado

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


Re: Win32 drive mapping... aka "net use"

2005-03-05 Thread Lucas Machado
I have already seen the "net help use" and i know how to manage samba
shares from a command prompt.  What i need help with is using the win32
api for python to manage shares....

--Lucas

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


handling pywintypes.error exceptions

2005-03-05 Thread Lucas Machado
I'm using the win32 api to map samba shares, and I'm having trouble
handling some exceptions.  In my script there are 2 possible exceptions
when the script attempts to map a share:

>>> win32net.NetUseAdd(None, 1, {'remote':r'\\foo\bar','local':'X
Traceback (most recent call last):
  File "", line 1, in ?
pywintypes.error: (53, 'NetUseAdd', 'The network path was not found.')

This exception occurs when '\\foo\bar' is not an existing share. Also,
when a drive letter is already in use the following occurs:

>>> win32net.NetUseAdd(None, 1,
{'remote':r'\\some_server\share','local':'Y:'})
Traceback (most recent call last):
  File "", line 1, in ?
pywintypes.error: (85, 'NetUseAdd', 'The local device name is already
in use.')

I know the exception raised in these cases is "pywintypes.error", but
how can i differentiate between the two exceptions? Being able to do
this is critical for my script

Thanks in advance,
--Lucas Machado

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


Re: Win32 drive mapping... aka "net use"

2005-03-05 Thread Lucas Machado
Roger Upole wrote:
> You could use win32api.GetLogicalDriveStrings to list
> the drive letters currently in use, and find the next free
> letter.  net use * probably does something like that under
> the covers.

I went and took your advice and this is where I am now:

>>> import win32api
>>> a = win32api.GetLogicalDriveStrings()
>>> a
'A:\\\x00C:\\\x00D:\\\x00E:\\\x00Z:\\\x00'
>>> print a
A:\ C:\ D:\ E:\ Z:\

So I think this function will work great since it gives me a string
that i can simply strip away what i don't need and then split it into a
list and traverse the list.  However, when I try to split it, the
following occurs:

>>> b = a.strip(r'\\\x00')
>>> b
'A:\\\x00C:\\\x00D:\\\x00E:\\\x00Z:\\\x00'
>>> b = a.split(r'\\\x00')
>>> b
['A:\\\x00C:\\\x00D:\\\x00E:\\\x00Z:\\\x00']

I'm a bit of a novice at python (even more so of the win32 api), but
I've used the split and strip functions before (for example to get rid
of '\n' from strings) so it is unclear to me why this does not work.

Thanks
--LM

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


Re: reading timestamp from vid file (avi)

2005-03-09 Thread Lucas Raab
flupke wrote:
Hi,
i capture a movie from mividv to an avi containing the dv video. I found 
a program that reads the timestamp from the avi so you know the exact 
date and time the video was shot. However, the source of that program is 
not available and it doesn't allow to batch process a directory of video 
files which is a pain if you import the video using "split scenes".

Is there a script/program in python that reads the header or where do i 
start to write something like that?

Any info is appreciated.
Regards,
Benedict
Take a look at pymedia at http://pymedia.org.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Linux Multimedia System

2005-03-13 Thread Lucas Raab
Marek Franke wrote:
Hi there,
we have started with some people from our LUG (Linux User Group) a 'little'
project, called LMMS (Linux Multimedia System). When it's 'finished' it
shall be a window-manager for use on TV and handle with joysticks/gamepads. 

As the name says, it is for multimedia-applications, like listening to
music, watching videos and maybe playing some games. The idea is to create
a gui for application like mplayer, ogg123, mpg123, cdrecord etc.
For now there are some widgets for displaying images, labels and some
messages. Actually there is a working LMMS with a little menu, an
image-viewer and a CD-player. Supperted joysticks/gamepads are Gravis
Gamepad Pro, Nintendo's SNES Pads, Microsoft's X-Box pad and keyboard.
The whole project is written in python/pygame and can be found here:
http://home.arcor.de/mfranke78/
There is a little mailinglist too (German & Yahoo):
http://de.groups.yahoo.com/group/dulugprojekt/
Remember that the whole project is very basic for now! But it seems to work.
Greets, Marek
Just wondering how you're supporting the Xbox controller. I bought a 
cable and driver a few months back to hook up to my computer. Are you 
using a Python alternative??

--
--
Lucas Raab
lvraab located at earthlink.net
dotpyFE located at gmail.com
AIM:Phoenix11890
MSN:[EMAIL PROTECTED]
IRC:lvraab
ICQ:324767918
Yahoo:  Phoenix11890
--
http://mail.python.org/mailman/listinfo/python-list


Re: Linux Multimedia System

2005-03-13 Thread Lucas Raab
Marek Franke wrote:
Hi there,
we have started with some people from our LUG (Linux User Group) a 'little'
project, called LMMS (Linux Multimedia System). When it's 'finished' it
shall be a window-manager for use on TV and handle with joysticks/gamepads. 

As the name says, it is for multimedia-applications, like listening to
music, watching videos and maybe playing some games. The idea is to create
a gui for application like mplayer, ogg123, mpg123, cdrecord etc.
For now there are some widgets for displaying images, labels and some
messages. Actually there is a working LMMS with a little menu, an
image-viewer and a CD-player. Supperted joysticks/gamepads are Gravis
Gamepad Pro, Nintendo's SNES Pads, Microsoft's X-Box pad and keyboard.
The whole project is written in python/pygame and can be found here:
http://home.arcor.de/mfranke78/
There is a little mailinglist too (German & Yahoo):
http://de.groups.yahoo.com/group/dulugprojekt/
Remember that the whole project is very basic for now! But it seems to work.
Greets, Marek
BTW, I'd be happy to help with a Windows version.
--
--
Lucas Raab
lvraab located at earthlink.net
dotpyFE located at gmail.com
AIM:Phoenix11890
MSN:[EMAIL PROTECTED]
IRC:lvraab
ICQ:324767918
Yahoo:  Phoenix11890
--
http://mail.python.org/mailman/listinfo/python-list


Re: Linux Multimedia System

2005-03-13 Thread Lucas Raab
Marek Franke wrote:
Just wondering how you're supporting the Xbox controller. I bought a
cable and driver a few months back to hook up to my computer. Are you
using a Python alternative??
No, I rebuild the connector to USB and loaded the xpad-driver (Linux),
that's all. Just the same with the SNES pads (parallel-support, not USB).
The xpad-driver loads automatically on startup, for the rest I have written
a little script:
#!/bin/sh
#echo Loading analog joystick support
#modprobe gameport
#modprobe analog
#modprobe ns558
#modprobe joydev
echo Loading parallel port support io=0x378 irq=7
modprobe parport_pc io=0x378 irq=7
echo Loading SNES gamepad support
modprobe gamecon map=0,1,1
#echo Loading 2 Button Mustisystem gamepad support
#modprobe db9 dev=0,2
After that I will get some new devices /dev/input/js* and they work fine
with python/pygame.
Marek
Huh. Interesting.
--
--
Lucas Raab
lvraab located at earthlink.net
dotpyFE located at gmail.com
AIM:Phoenix11890
MSN:[EMAIL PROTECTED]
IRC:lvraab
ICQ:324767918
Yahoo:  Phoenix11890
--
http://mail.python.org/mailman/listinfo/python-list


Re: Protecting Python source

2004-11-30 Thread Lucas Raab
Peter Hansen wrote:
Gustavo CÃrdova Avila wrote:
Peter Maas wrote:
Grant Edwards schrieb:
On 2004-11-29, Peter Maas <[EMAIL PROTECTED]> wrote:
If the "reverse engineering" argument boils down to "protecting source
doesn't make sense" then why does Microsoft try so hard to  protect
its sources?

To avoid embarassment.

:) This cannot be the whole truth otherwise they wouldn't release
embarrasing binaries.

BWAAHHAHAHA!!!
Damn you!! Coke is so hard to clean off a keyboard!!

Yeah, I hate the way the powder builds up between the keys.
Oh.
You meant the _drink_...
-Peter
Nice. Very nice!!
--
http://mail.python.org/mailman/listinfo/python-list


Problems getting TwistedMatrix

2004-12-07 Thread Lucas Raab
Has anybody who has recently downloaded Twisted seem to have any 
problems with downloading it?? I'm a dial-up user (which might be why) 
and whenever I click the link to download it it takes 30+ for a 1.8 MB 
file, which should take only about 7-10.
--
http://mail.python.org/mailman/listinfo/python-list


Performance (pystone) of python 2.4 lower then python 2.3 ???

2004-12-13 Thread Lucas Hofman
Hi,

Just installed Python 2.4 on a machine (RH8.0 Linux) that also has python 2.3
and python 2.2 installed. The latter came with the linux distribution, the other
are compiled from source tarballs.

Comparing them gives the following unexpected result:

[EMAIL PROTECTED] test]$ /usr/bin/python pystone.py
Pystone(1.1) time for 5 passes = 1.86
This machine benchmarks at 26881.7 pystones/second
[EMAIL PROTECTED] test]$ /usr/local/bin/python2.3 pystone.py
Pystone(1.1) time for 5 passes = 1.22
This machine benchmarks at 40983.6 pystones/second

This is ok, a 52% speed increase, but:

[EMAIL PROTECTED] test]$ /usr/local/bin/python2.4 pystone.py
Pystone(1.1) time for 5 passes = 1.31
This machine benchmarks at 38167.9 pystones/second

A 7% speed DECREASE??? According to the documentation it should be a 5% 
increase?

The machine is a 3.0 GHz Xeon box.

Both python 2.3 and 2.4 where configure without any options.

Anyone who understands what is going on?

Regards, Lucas

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


Re: Performance (pystone) of python 2.4 lower then python 2.3 ???

2004-12-13 Thread Lucas Hofman
Nick Craig-Wood  craig-wood.com> writes:

> 
> Peter Hansen  engcorp.com> wrote:
> >  For comparison, I do get a decent speedup.  Machine is an
> >  AMD Athlon XP 2500+ (1.82GHz) running Win XP Pro SP2.
> > 
> >  Python 2.3.4: 36393 pystones.
> >  Python 2.4:   39400 pystones.
> > 
> >  ...about an 8% speedup.
> 
> On my 2.6 GHz P4 running debian testing I got the following results :-
> 
> $ for p in 2.1 2.2 2.3 2.4; do echo $p; python$p pystone.py 100 ; done
> 
> 2.1
> Pystone(1.1) time for 100 passes = 40.67
> This machine benchmarks at 24588.1 pystones/second
> 2.2
> Pystone(1.1) time for 100 passes = 39.64
> This machine benchmarks at 25227 pystones/second
> 2.3
> Pystone(1.1) time for 100 passes = 32.49
> This machine benchmarks at 30778.7 pystones/second
> 2.4
> Pystone(1.1) time for 100 passes = 29.88
> This machine benchmarks at 33467.2 pystones/second
> 
> Showing that 2.4 is the fastest so far!  (And is also a good advert
> for AMD 
> 


I got this list on a single processor P4 1.6 Ghz:
2.1
Pystone(1.1) time for 10 passes = 6.74
This machine benchmarks at 14836.8 pystones/second
2.2
Pystone(1.1) time for 10 passes = 6.36
This machine benchmarks at 15723.3 pystones/second
2.3
Pystone(1.1) time for 10 passes = 4.92
This machine benchmarks at 20325.2 pystones/second
2.4
Pystone(1.1) time for 10 passes = 4.51
This machine benchmarks at 22172.9 pystones/second

Which shows the expected speedup.

On a dual Xeon 3.0 Ghz:
2.2
Pystone(1.1) time for 100 passes = 37.45
This machine benchmarks at 26702.3 pystones/second
2.3
Pystone(1.1) time for 100 passes = 25.28
This machine benchmarks at 39557 pystones/second
2.4
Pystone(1.1) time for 100 passes = 25.94
This machine benchmarks at 38550.5 pystones/second

Which shows a decrease in performance. Could this have anything to do with the
fact that is is a dual processor box?

Lucas

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


Re: Performance (pystone) of python 2.4 lower then python 2.3 ???

2004-12-13 Thread Lucas Hofman
Mark Asbach wrote:
Hi Lucas,

On a dual Xeon 3.0 Ghz:

[...]

Which shows a decrease in performance. Could this have anything to do with the
fact that is is a dual processor box?

Maybe. But my 3Gh P4/HT is also detected as a dual processor machine
(Kernel 2.6), so it might be a general problem with the Xeon?
Hi Mark,
No,the reason that you see 2 times as many processors as really are 
installed is the hyperthreading feature of the Xeon (see 
http://www.infoworld.com/infoworld/article/02/02/25/020225plxeon_1.html)

I turned it off (in the BIOS). The machine I tested on has 2 (pysical) 
processors installed. Turning on or off does not influence the pystone 
number significantly..

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


Re: Performance (pystone) of python 2.4 lower then python 2.3 ???

2004-12-14 Thread Lucas Hofman
Istvan Albert  mailblocks.com> writes:

> 
> Lucas Hofman wrote:
> 
> > Anyone who understands what is going on?
> 
> It is difficult to measure a speedup that might be
> well within your measurement error.
> 
> Run the same pystone benchmark repeatedly and
> see what variation you get.
> 
> Istvan.

Very little variation actually. The system measured is only lightly loaded (and
it is a 2 processor box). I ran the benchmark > 4 times and got 3 results that
are within 1% of each other.

Lucas


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


Re: python & nurbs

2004-12-19 Thread Lucas Raab
Jelle Feringa // EZCT / Paris wrote:
Hint to get a useful answer: Define your needs.  Display in 3D (want to
use them to define and display geometry)?  Numeric analysis (writing
some sort of CAD or automation system)?  Modeling system (want some way
to interactively define them)?

I wish I could give you a well defined answer to this.
At the moment I'm fed up by the limited capabilities of mainstream cad
modelers such as Rhino. I'm interested in using for instance Gaussian
curvature functions to model geometry. More interested in computing rather
than drawing. The problem so far is that either you computer or draw. I'm
looking for something that would do both. For instance I've been studying to
script Rhino (using COM) which looks promising, but since Rhino isn't a
parametric modeler, it wont meet my need. Topsolid looks like an option.
Too bad blender doesn't have any cad/parametric capabilities, that could
have been a sweet option

OpenGLContext has a set of NURBs nodes modeled after the VRML97 NURBs
extension, though they don't see all that much usage.  I would imagine
some of the other retained-mode systems have them as well.
My collection of links to retained-mode engines is here:
   http://www.vrplumber.com/py3d.py?category=retained

Col! I've had a few look arounds your site, its GREAT!!! Best
python/graphic portal I've seen so far! Thank you!!!

If you want something for doing numeric analysis of NURBs, don't know
where you'd find it.
Many 3D modelers will let you create nurbs surfaces.  IIRC Rhino was the
pre-eminent NURBs-focused modeler a few years ago.

Rhino has been my tool of trade for quite some time.
Time to move over to an environment to profoundly supports python scripting!
My feeling is that Rhino is getting out of date rapidly by the lack of
parametric modeling. But let me stop discussing this soft on this list...
Thanks for your feedback so far!

Have you looked at Blender (http://www.blender3d.com)??
--
http://mail.python.org/mailman/listinfo/python-list


Re: Funny story about python

2004-12-20 Thread Lucas Raab
[snip]
eScrew
eScrew will keep writing this shit because eScrew enjoys to masturbate
your spiritual sense of self eScrew
Awww, it was such a good story until now.
--
http://mail.python.org/mailman/listinfo/python-list


Re: getting text from WinXP console

2005-03-21 Thread Lucas Raab
Chris Maloof wrote:
Hello,
Does anyone know how I can read the ASCII text from a console window
(from another application) in WinXP?  It doesn't sound like a major
operation, but although I can find the window via pywin32, I haven't
been able to do anything with it.  I'd really just like to get the
window text into a string.
By "console window", I mean the sort of thing that comes up when you
run "command" (although this particular one is for the game NetHack).
Thanks,
Chris
If you're looking to do this from Python then do "python  > 
output.txt" only without the quotes. AFAIK, this only works on Windows. 
Correct me if it works from Linux or another OS.

--
--
Lucas Raab
lvraab located at earthlink.net
dotpyFE located at gmail.com
AIM:Phoenix11890
MSN:[EMAIL PROTECTED]
IRC:lvraab
ICQ:324767918
Yahoo:  Phoenix11890
--
http://mail.python.org/mailman/listinfo/python-list


Re: getting text from WinXP console

2005-03-21 Thread Lucas Raab
Jeff Schwab wrote:
Lucas Raab wrote:
Chris Maloof wrote:
Hello,
Does anyone know how I can read the ASCII text from a console window
(from another application) in WinXP?  It doesn't sound like a major
operation, but although I can find the window via pywin32, I haven't
been able to do anything with it.  I'd really just like to get the
window text into a string.
By "console window", I mean the sort of thing that comes up when you
run "command" (although this particular one is for the game NetHack).
Thanks,
Chris

If you're looking to do this from Python then do "python  
> output.txt" only without the quotes. AFAIK, this only works on 
Windows. Correct me if it works from Linux or another OS.

It works on Unix. :)
Alright. Thanks, I wasn't sure.
--
--
Lucas Raab
lvraab located at earthlink.net
dotpyFE located at gmail.com
AIM:Phoenix11890
MSN:[EMAIL PROTECTED]
IRC:lvraab
ICQ:324767918
Yahoo:  Phoenix11890
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python for a 10-14 years old?

2005-03-23 Thread Lucas Raab
[EMAIL PROTECTED] wrote:
Hi,
I am blessed with a *very* gifted nine-years old daughter for whom I
have recently installed an old GNU/Linux Mandrake 7.2 on an equally old
Pentium Pro box.  She is enjoying it tremendously and has no problems
understanding simple desktop operations and the file system basics
(Needless to say - she has already mastered the 30 or so games I
installed for her).
Now, I would like to teach her programming basics using Python (because
I believe it is best suited for this purpose and, yes, also because it
is my favorite language).  The only tutorial I have found so far is
"How to Think Like a Computer Scientist - Learning with Python" which,
while very good indeed, is geared towards adult newbie students.
Is there something out there like "Python for kids" which would explain
*basic* programming concepts in a way which is accessible and
entertaining for kids aged 10-14 (that about where her brain is right
now) and which would allow them to "play around" and have fun solving
small problems?
Many thanks in advance,
TN
Let her mess around with it on her own. I'm 15 and have been using 
Python for 2-3 years and had nothing to really go on. Give her Dive Into 
Python or How to Think Like a Computer Scientist and let her ask 
questions if she needs help.

--
--
Lucas Raab
lvraab located at earthlink.net
dotpyFE located at gmail.com
AIM:Phoenix11890
MSN:dotpyfe "@" gmail.com
IRC:lvraab
ICQ:324767918
Yahoo:  Phoenix11890
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python for a 10-14 years old?

2005-03-25 Thread Lucas Raab
Leif B. Kristensen wrote:
R.Meijer wrote:

Jot  nad.com> writes:

If she's really gifted i hope she dumps that obsolete monolithic
kernel as soon as she realizes that such beautiful language as python
shouldn't be used on top of ugly, badly designed software.
Did somebody say off-topic?

I'd say it's a "Troll -1". Anyway, that'd be my moderator response over
at Slashdot. As had been said so many times; GNU/Hurd is still a
pipe-dream. Those who think that the Linux kernel is based on faulty
concepts should really get their act together and produce their own
microkernel. Personally, I don't care about the kernel architecture as
long as I've got a system that works right here, now.
 

Anyway, I myself am 14 years old and I can make simple python scripts
already by learning it off the official tutorial that comes with it.
My tip: let her take her time with a normal adult tutorial, and give
her small assignments every few chapters just so she gets it.

If I may ask, do you think that the "How to think like a Computer
Scientist" is a good starter? I'm 52 years old and learned my basics
with Swan's "Mastering Turbo Pascal 5.5" way back when, but I'm
sincerely wondering what your generation think are hi-class tutorials.
I've got a thirteen-year old daughter to whom I have recently taught the
HTML basics, but she doesn't readily take to actual programming. If
you've got any idea what I should push to her to get her fascinated
about _real_ programming, I'd be obliged. Or maybe her head isn't
screwed together that way, what do I know.
I found "How to Think Like a Computer Scientist" a very good book. It 
was very well written and didn't push too many things onto you at once.

--
--
Lucas Raab
lvraab located at earthlink.net
dotpyFE located at gmail.com
AIM:Phoenix11890
MSN:dotpyfe "@" gmail.com
IRC:lvraab
ICQ:324767918
Yahoo:  Phoenix11890
--
http://mail.python.org/mailman/listinfo/python-list


AAC extracton

2005-03-30 Thread Lucas Raab
In a M4A file encoded with iTunes, persay, how does one extraction the 
AAC data?? I'm looking into a project using pymedia and I know it 
supports the AAC format, but how does the extraction of AAC data work?? 
Just going a certain number of bytes into the file??

TIA
--
--
Lucas Raab
lvraab"@"earthlink.net
dotpyFE"@"gmail.com
AIM:Phoenix11890
MSN:dotpyfe"@"gmail.com
IRC:lvraab
ICQ:324767918
Yahoo:  Phoenix11890
--
http://mail.python.org/mailman/listinfo/python-list


Re: Change between Python 2.3 and 2.4 under WinXP

2005-04-04 Thread Lucas Raab
Fredrik Lundh wrote:
Franz Steinhäusler wrote:

My second question from my last post (PyQt on Python 2.4), I think, is
a little got under (i have installed both Python 2.3 and Python 2.4)
Is there any possibility under WinXP, to alterntate quickly
(with batch file or similary) between python23 and python24.

if you want to deploy programs that depend on a specific python version,
exemaker is your friend:
http://effbot.org/zone/exemaker.htm
 


not to be biased toward your own products at all, or course :-)
--
--
Lucas Raab
lvraab"@"earthlink.net
dotpyFE"@"gmail.com
AIM:Phoenix11890
MSN:dotpyfe "@" gmail.com
IRC:lvraab
ICQ:324767918
Yahoo:  Phoenix11890
--
http://mail.python.org/mailman/listinfo/python-list


Re: What's up with the PyFX Project??? (ex PyCG nVidia CG implementation)

2005-04-04 Thread Lucas Raab
tc wrote:
Does anyone know why there's no progress on the pyfx project??
(http://graphics.cs.lth.se/pyfx)
What are the pro and con's for such an implementation to actually
program a 3d game (engine)??
I started off a while ago in c++ to play around a bit with directx
opengl and cg but I'd rather like to program in a language such as
python...
PyGame doesn't meet my need's because i'd like to take adantage of the
much faster directx technology.
Any comments, hints?
Greets TC
Panda3D might be what you're looking for. http://panda3d.etc.cmu.edu. 
It's an open-source 3D engine. Python is the main language used to 
program the games. While you can use C++ or other languages, they aren't 
as well supported.

--
--
Lucas Raab
lvraab"@"earthlink.net
dotpyFE"@"gmail.com
AIM:Phoenix11890
MSN:dotpyfe"@"gmail.com
IRC:lvraab
ICQ:324767918
Yahoo:  Phoenix11890
--
http://mail.python.org/mailman/listinfo/python-list


trouble using \ to escape %

2005-04-15 Thread Lucas Machado
I'm writing a python script that modifies the smb.conf file, and i need
to write the characters '%U' in the file.  I tried making a string like
so:

str1 = "[%s%s]\n\tpath = /mnt/samba/%s%s/\%U" % (list[0], list[1],
list[0], list[1])

but i keep getting: "TypeError: not enough arguments for format
string". I've also tried making the string:

str1 = "[%s%s]\n\tpath = /mnt/samba/%s%s/\%" % (list[0], list[1],
list[0], list[1])

but i get: "ValueError: incomplete format". These errors lead me to
believe that for some reason it is not escaping the '%' character.
There has to be a way to write '%' to a file. Thanks in advance..

Cheers
-Lucas Machado

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


Re: Can .py be complied?

2005-04-27 Thread Lucas Raab
[EMAIL PROTECTED] wrote:
[EMAIL PROTECTED] wrote:
I don't know the exact details, but try using the compiled Python
scripts (bytecode). I believe they are semi-optimized and platform
independent. They are the .pyc and .pyo files generated when the
script
is run.

Okay, I found this documentation
<http://fux0r.phathookups.com/programming-tutorials/Python/tut/node43.html>.
It hides the source but you still need Python installed on the system
running the bytecode.
But those files can be decompyled.
--
--
Lucas Raab
lvraab"@"earthlink.net
dotpyFE"@"gmail.com
AIM:Phoenix11890
MSN:dotpyfe"@"gmail.com
IRC:lvraab
ICQ:324767918
Yahoo:  Phoenix11890
--
http://mail.python.org/mailman/listinfo/python-list


Drag and Drop Images in Python (NEED HELP!)

2015-01-01 Thread lucas mvm
Hi at all user!

I used Tkinter and canvas to make a window and i added 2 transparent .png 
images. So when i start my programm it just shows the 2 images.
I want to drag one image above the other image and than it will disappear.
So I need help with "drag and drop images"

heres my code if you want to have a look, its basically just displaying 2 
images but i want to drag 1 image above the other one..



#pythonprogramm "feed"
from tkinter import * #importing tkinter
f = Tk()
f.title('Give the boy his apple.')
f.geometry('500x500')
c = Canvas(master=f,width=500,height=500,bg='white')
c.place(x=0,y=0)
p = PhotoImage(file='sadsmiley.png') #sad smiley image
i = c.create_image(250,320,image=p) #genaue position
p2 = PhotoImage(file='food.png') #food image (should be dropped on sadsmiley)
i2 = c.create_image(70,100,image=p2)
f.geometry('500x500')
f.mainloop()



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


Yet Another Switch-Case Syntax Proposal

2014-04-02 Thread Lucas Malor
Hi all. I would proposeto you all a switch-case syntax for Python. I already 
read PEP 3103 and I'm not completely satisfied by any of the proposed 
solutions. This is my proposal:

switch_stmt ::=  "switch" identifier "case" expression_list ":" suite
("case" expression_list ":" suite)*
["else" ":" suite]

or, more simply:



switch x case var1:

case var2:
...
case var3:
...
else:
...



Expression list should yield an iterable. The case suite will be executed if 
the variable of the identifier is a member of the iterable. 

For example, in a "switch x" statement, the code "case iterable: " is identical 
to "if x in iterable: " (or elif etc). So if you want to perform the same case 
block for more than one value, you have only to specify a tuple, a range etc. 
I would suggest to add an exception for non-iterable variables, so that you 
don't have to write "case var, : " but simply "case var: " and it will be 
identical to "if x == var: ". It's a bit tricky but the alternative is ugly.

Fallthrough is disabled by default. The continue keyword cause to skip all the 
remaining current case suite. The next case will be checked. You can't use the 
continue keyword in the else clause.

Some random remarks:
1. switch is on the same line of the first case. This will avoid any unpythonic 
syntaxes like:
switch x
case var1:
...

or 

switch x:
case var1:
...

2. Fallthrough is disabled by default because IMHO it's what non-programmers 
expect and that's what programmer usually needs more. I don't think a switch 
with such a syntax needs a break statement. 

3. As an alternative, the continue statement could be written only at the end 
of a case suite; it will be less powerful and not consistent with the other 
compound statements, but it will improve readability.

4. I decided to not use already existing keyword like "if" or "in", since it 
will be misleading and problematic for syntax highlighters.


Tell me what you think about.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Yet Another Switch-Case Syntax Proposal

2014-04-03 Thread Lucas Malor
Thank you for reading and commenting my proposal. Here are my replies:

In reply to Chris Angelico:

> I don't like the "iterable vs non-iterable" distinction. Compare: [...]
> case "Test": # And there's your problem.

Yes, I had already thought after I posted that testing against string it's a 
problem. But I think that the more practical and unambiguous solution is to 
introduce also "casein" as a new keyword. So if you want to test a string:

switch mystring case "-h":
print_usage()
case "--version"
print_version()

If you want to test against membership:

switch mychar casein "aeiou":
mychar.vocal = True

I prefer "casein" instead of "case in" for the same reason Python uses "elif" 
instead of "else if".



In reply to Ian Kelly:

> A more suitable place to propose this would be the python-ideas mailing list.

You're right. I posted here because this list was linked by PEP 1. But now that 
I read more there's also python-ideas listed. Let me know if I have to continue 
there instead.

> Why just just an identifier after the switch keyword instead of an expression?

Because I wronged, it can be an expression_list as well.

> An expression_list is one or more independent expressions separated by commas 
> that 
> don't create a tuple.

Well, py docs state "An expression list containing at least one comma yields a 
tuple".

> __contains__ is not part of the interface for iterables

For what I know there's not an Iterable interface. For example List simply 
extends Object. I hope that an ABC Iterable class will be introduced in a 
future. 
Anyway, I think that "switch x casein y" should simply raise a TypeError if y 
doesn't implement __contains__, like "x in y" do.

> If we overload the continue keyword in this way, then a continue can't be 
> used within the switch
> to control a loop that the switch is nested within.

Well, this is the same problem for, say, a for loop nested inside another for 
loop, and you can solve it with the same methods.

> Instead of disabling fallthrough by default, why not disable it all together?

I was tempted but there are cases in which it's useful. An example

switch day casein ("Monday", "Thursday", "Wednesday", "Tuesday", "Friday"):
gotowork = True
continue
casein ("Monday", "Thursday", "Wednesday", "Tuesday", "Friday"):
daytype = "ferial"
casein ("Saturday", "Sunday")
daytype = "festive"
-- 
https://mail.python.org/mailman/listinfo/python-list


  1   2   >