Re: send function keys to a legacy DOS program

2011-03-11 Thread jr
On Mar 10, 7:58 pm, Justin Ezequiel 
wrote:
> Greetings,
>
> We have an old barcode program (MSDOS and source code unavailable.)
> I've figured out how to populate the fields (by hacking into one of
> the program's resource files.)
> However, we still need to hit the following function keys in sequence.
> F5, F2, F7
> Is there a way to pipe said keys into the program?
>

Use "expect" on unix or "pexpect" if you're looking for the python
implementation.
-- 
http://mail.python.org/mailman/listinfo/python-list


msnp, friends list

2005-02-17 Thread jr
I'm currently using the msnp.py code from Manish Jethani's project. I
havn't been able to get the friends list to update like it should. it
works once out of about every 25 times the program loads.

Has anyone been able to implement his code and get the friends list to
actively update? Or have any suggestions?

Any info would be great.
Thanks.

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


Re: msnp, friends list

2005-02-17 Thread jr
Sorry, I guess what I meant to ask was the status of the friends in the
friends list begin updated. Right now we have a friends list which is
being populated with the correct users, but their status (online,
offline) is never getting set. For some reason the events aren't being
fired??

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


Re: msnp, friends list

2005-02-18 Thread jr
Mark,
Thank you so much for that information. Been struggling with this issue
for quite some time now. A simle line comment on line 647 of session.py
solves all problems :)
this line sets your status to online and does not get time (usually) to
get friends list correctly.

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


Re: Format a number as currency! I can't find any help on this simple problem.

2006-10-17 Thread jr
Hi, Bernard.
Just tried the first 2 commands on win XP, Python 2.5 under Idle.
An Error is raised: "unsupported locale setting" (lib/locale.py in
setlocale, line 476).
Actually I get the error also under Python 2.4.3
Any idea what I'm missing?
Thanks in advance.
Jürgen
Bernard wrote:
> >>> import locale
> >>> locale.setlocale(locale.LC_ALL, 'English_United States.1252')
> 'English_United States.1252'
> >>> conv = locale.localeconv()
> >>> x = 1234567.8
> >>> locale.format("%d", x, grouping=True)
> '1,234,567'
> >>> locale.format("%s%.*f", (conv['currency_symbol'], 
> >>> conv['int_frac_digits'], x), grouping=True)
> '$1,234,567.80'
>
> Hi Richards,
>
> This works for me. I agree it's a bit complicated compared to C# but it
> works. I'd put it in a function if I had to use it.
>
>
> Richard Kessler wrote:
> > I am relatively new to Python.  Love it, but I find things that I can do
> > easily in .NET and cannot find a way to do in Python. I need to format a
> > number as currency, for example 12343.56 to $12,343.56.
> >
> > In C# all I need to do is decimal x = 12343.56 then 
> > x.ToString("$###,###.00");
> >
> > I cannot find a way to do this in Python. I must be missing something very
> > simple here. I have tried the locale module but it will not put in the 
> > commas.
> > I hope I do not have to write my own formatting routine...surely one is out
> > there and I just can't find it.
> >
> > Running on XP Pro. Python 2.4.3.
> > 
> > Thanks much in advance,
> > 
> > Richard

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


'gcc' failed with exit status 1

2010-03-23 Thread JR
Hello All,

I was hoping I could get some help with this issue with getting Cython
to work. Earlier I had an issue that said "unable to find
vcvarsall.bat" and it turns out there is an active bug report that
covers that issue (I have a 64 bit windows system). I still hadn't
installed 3.1.2, so I did that tonight and now I have the issue below.
Any thoughts on what I am doing wrong?



Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\James>cd C:\Python31

C:\Python31>python setup.py build_ext --inplace
running build_ext
cythoning hello.pyx to hello.c

Error converting Pyrex file to C:

...
def say_hello_to(name):
  ^


C:\Python31\hello.pyx:1:23: Unrecognized character
building 'hello' extension
C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python31\include -
IC:\Pytho
n31\PC -c hello.c -o build\temp.win-amd64-3.1\Release\hello.o
hello.c:1:2: #error Do not use this file, it is the result of a failed
Cython co
mpilation.
error: command 'gcc' failed with exit status 1

C:\Python31>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: 911 FORGERY bigger than the Protocols of the Learned Elders of Zion

2006-09-16 Thread JR North
LOOK OUT! He has a bomb strapped to him!
JR
Dweller in the cellar

[EMAIL PROTECTED] wrote:

> Do not bury your head in the sand ... Do not practice denial ... It
> will only bring you to terrible shame and grief ... Do not be afraid of
> saying the truth ... Do not be afraid of death ... God will take care
> of you and your kins as he took care of the flock of Abraham, Moses and
> Jesus.
> 
> Here you will find all the truth, movies, audios and proof for your
> eyes to see (even the swiss are beginning to doubt 911) :
> 
> www.scholarsfor911truth.org
> www.journalof911studies.org
> www.st911.org
> 
> also go to Alex Jones site:
> 
> infowars.com
> prisonplanet.com
> 
> Distribute fliers on the site at your churches and synagogues, in your
> schools. Call your elected officials. Mail anonymously to your local
> fire station chiefs and your local police
> sherrifs. Send, to any and all CIA, FBI, Military personell and Court
> Judges that you know.
> 
> We need to move fast and quick before the terrorists of 911 bring
> another false flag terrorism
> which may be biological, nuclear or what we cannot even imagine.
> 
> They dont care about the lives or the freedom of the american people.
> They only love their evil agendas.
> 
> God Bless you All
> 
> Search Keywords:
> Thermate
> Sulfur
> Potassium
> Manganese
> Aluminum
> Thermite
> Alex Jones
> Steven Jones
> Controlled Demolition
> Popular Mechanics
> Larry Silverstein
> Marvin Bush
> Stratcor
> Stratesec
> Ground Zero
> 


-- 
--
Home Page: http://www.seanet.com/~jasonrnorth
   If you're not the lead dog, the view never changes
 Doubt yourself, and the real world will eat you alive
  The world doesn't revolve around you, it revolves around me
 No skeletons in the closet; just decomposing corpses
--
Dependence is Vulnerability:
--
"Open the Pod Bay Doors please, Hal"
"I'm sorry, Dave, I'm afraid I can't do that.."
-- 
http://mail.python.org/mailman/listinfo/python-list


i'm a python newbie & wrote my first script, can someone critique it?

2016-06-10 Thread mad scientist jr
Is this group appropriate for that kind of thing? 
(If not sorry for posting this here.)

So I wanted to start learning Python, and there is s much information 
online, which is a little overwhelming. I really learn best from doing, 
especially if it's something actually useful. I needed to create a bunch of 
empty folders, so I figured it was a good exercise to start learning Python. 
Now that it's done, I am wondering what kind of things I could do better. 
Here is the code: 

# WELCOME TO MY FIRST PYTHON SCRIPT!
# FIRST OF ALL, IT ***WORKS***!!! YAY!
# I AM A VBA AND JAVASCRIPT PROGRAMMER, 
# SO IT IS PROBABLY NOT VERY "PYTHONIC", 
# SO PLEASE FEEL FREE TO TEAR THE SCRIPT A NEW ONE
# AFTER YOU ARE SHOCKED BY THIS BAD CODE, 
# ALL I ASK IS THAT IF YOU THINK SOMETHING IS BAD, 
# PLEASE POST AN EXAMPLE OF THE "CORRECT" WAY OF DOING IT
# COMING FROM VBA, I KNOW A LITTLE OOP,
# BUT NOT C++ C# JAVA STUFF LIKE "INTERFACES" AND "ABSTRACT BASE CLASSES"
# SO IF YOU GET INTO SUCH TERMINOLOGY MY EYES MIGHT START TO GLAZE OVER
# UNLESS YOU CARE TO EXPLAIN THAT TOO


# GLOBAL VALUES
sForPythonVersion="3"
#sFolderPathTemplate = "c:\\myscripts\\MP3 Disc "
sFolderPathTemplate = "c:\\temp\\MP3 Disc "
iFromCount = 1
iToCount = 250
iCountWidth = 3


# SUPPORT FUNCTIONS

# 
//
def is_string(myVar): # is_string IS MORE READABLE THAN isinstance (PLAIN 
ENGLISH!)
#PYTHON 3 IS NOT LIKING THIS: return ( isinstance(myVar, str) or 
isinstance(myVar, unicode) )
#PYTHON 3 IS NOT LIKING THIS: return isinstance(myVar, basestr)
return isinstance(myVar, str)

# 
//
# THIS IS SOME SAMPLE FUNCTION FROM A BOOK I AM READING "PYTHON IN EASY STEPS"
def strip_one_space(s):
if s.endswith(" "): s = s[:-1]
if s.startswith(" "): s = s[1:]
return s

# 
//
def get_exact_python_version():
import sys
sVersion = ".".join(map(str, sys.version_info[:3]))
sVersion = sVersion.strip()
return sVersion

# 
//
# TO DO: RETURN TO THE LEFT OF FIRST "."
def get_python_version():
sVersion = get_exact_python_version()
return sVersion[0:1]

# 
//
# CHECK PYTHON VERSION, IF IT'S WRONG THEN GRACEFULLY EXIT BEFORE IT BLOWS UP
# (DAMN, PYTHON 2.x STILL COMPLAINS WITH SYNTAX ERRORS!!)
# MAYBE THIS COULD STILL BE USEFUL FOR CHECKING THE SUB-VERSION, IN THAT CASE
# TO DO: MORE GRANULAR CHECK, EG IF VERSION >= 3.5.0
def exit_if_wrong_python_version(sRightVersion):
import os
sCurrentVersion = get_python_version()
if (sCurrentVersion != sRightVersion):
print("" +
  "Wrong Python version (" +
  sCurrentVersion +
  "), this script should be run using Python " +
  sRightVersion +
  ".x. Exiting..."
  )
os._exit(0)

# 
//
def get_script_filename():
import os
return os.path.basename(__file__)

# 
//
def get_timestamp():
import datetime
return datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d 
%H:%M:%S')

# 
//

def create_folder(sPath):
import os
import errno
#if not os.path.exists(directory):
#os.makedirs(directory)
try:
os.makedirs(sPath, exist_ok=True)
except OSError as exception:
#if exception.errno != errno.EEXIST:
print("ERROR #" + str(exception.errno) + "IN makedirs")
raise

# 
/

Re: i'm a python newbie & wrote my first script, can someone critique it?

2016-06-11 Thread mad scientist jr
Thanks to everyone for your replies.  I see my script was as horrific as I 
feared, but I read all the responses and made a few changes.  I'm not 100% sold 
on not checking types, but took it out, because it made sense that other 
programmers might want to use some custom type with my functions for their own 
nefarious purposes.  

One question I have is, can someone point me to a full listing of all the error 
types I can trap for?  It seems like a Pandora's box, trying to think of all 
the things that could go wrong, which is why I originally just printed the 
error #. Is it better to not trap errors, and let the stack trace tell what 
went wrong?  Does it give all the information on the error type etc.?

Anyway, for those charitable (or masochistic, or both) enough to critique my 
code again, here is the updated version:

# For Python 3.x

# This script creates multiple numbered empty folders
# in the desired location. To change the folder names
# or location, edit function get_default_options.

###
# REFERENCE MODULES
###
import datetime
import os
import errno
import sys

###
# SUPPORT FUNCTIONS
###

# returns: dictionary containing options for this script
def get_default_options():
dict = {
"s_for_python_version": "3",
"s_folder_path_template": "C:/temp/test/MP3 Disk {count:03}", 
"i_from_count": 3,
"i_to_count": 7,
}
return dict

# returns: string containing exact version #, eg "3.5.1"
# TODO: update to use
#   sys.version_info[:3] by itself gives a three-element tuple.
#   Probably easier to use than thestring version. 
#   A couple alternatives: 
#   sys.version[:5] or perhaps a bit safer -- sys.version.split()[0] both 
directly give you the 
#  string version.  (Note this uses version not version_info.)
def get_exact_python_version():
s_version = ".".join(map(str, sys.version_info[:3]))
s_version = s_version.strip()
return s_version

# returns: string containing general version #, eg "3"
# TODO: return to the left of first "."
def get_general_python_version():
s_version = get_exact_python_version()
return s_version[0]

# checks python version
# if it's wrong then gracefully exit before it blows up
# (damn, python 2.x still complains with syntax errors!!)
#
# receives:
#   s_right_version (string) = python version # to check against
# 
# TODO: more granular check, eg if version >= 3.5.0
def exit_if_wrong_python_version(s_right_version):
s_current_version = get_general_python_version()
if (s_current_version != s_right_version):
print(
"Wrong Python version ({}), "
"this script should be run using " 
"Python {}.x,  Exiting..."
"".format(s_current_version, s_right_version))
sys.exit() # SAME AS os._exit(0)

# assists in script readability
# returns: string containing name of the current script
def get_script_filename():
return sys.argv[0]

# returns: string containing the current date/time in the format eg 2016-05-22 
13:01:55
def get_timestamp():
return datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d 
%H:%M:%S')

# creates a folder at the specified path
# receives:
#   s_path (string) = full path of folder to create
def create_folder(s_path):
try:
os.makedirs(s_path, exist_ok=True)
except (FileExistsError, IsADirectoryError) as e:
print("FileExistsError IN makedirs")
raise
return False
except OSError as exception:
print("ERROR #" + str(exception.errno) + "IN makedirs")
raise
return False
print("" + get_timestamp() + " " + "Created folder: " + s_path + "")

# creates multiple numbered folders named per template
# receives:
#   s_folder_path_template (string) = template containing full path of folder 
to create,
# where "{count:n}" is replaced by the 
folder count (n digits)
#   i_from_count (int) = number to begin counting at
#   i_to_count (int) = number to stop counting after
#
# returns: count of folders created, 0 if error or none
def create_folders(
s_folder_path_template:str="",
i_from_count:int=1,
i_to_count:int=0
):
i_count=0
for i_loop in range(i_from_count, i_to_count + 1): 
create_folder(s_folder_path_template.format(count=i_loop))
i_count += 1

return i_count

###
# MAIN LOGIC
###

def main():
options_dict = get_default_options()
exit_if_wrong_python_version(options_dict["s_for_python_version"])
   

Re: i'm a python newbie & wrote my first script, can someone critique it?

2016-06-11 Thread mad scientist jr
For those who don't want to have to wade through comments, here is a version 
without so many comments:

# For Python 3.x
# This script creates multiple numbered empty folders
# in the desired location. To change the folder names
# or location, edit function get_default_options.

import datetime
import os
import errno
import sys

###
# EDIT VALUES HERE TO CUSTOMIZE THE OUTPUT
def get_default_options():
dict = {
"s_for_python_version": "3",
"s_folder_path_template": "C:/temp/test/MP3 Disk {count:03}", 
"i_from_count": 3,
"i_to_count": 7,
}
return dict
###

def get_exact_python_version():
s_version = ".".join(map(str, sys.version_info[:3]))
s_version = s_version.strip()
return s_version

def get_general_python_version():
s_version = get_exact_python_version()
return s_version[0]

def exit_if_wrong_python_version(s_right_version):
s_current_version = get_general_python_version()
if (s_current_version != s_right_version):
print(
"Wrong Python version ({}), "
"this script should be run using " 
"Python {}.x,  Exiting..."
"".format(s_current_version, s_right_version))
sys.exit()

def get_script_filename():
return sys.argv[0]

def get_timestamp():
return datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d 
%H:%M:%S')

def create_folder(s_path):
try:
os.makedirs(s_path, exist_ok=True)
except (FileExistsError, IsADirectoryError) as e:
print("FileExistsError IN makedirs")
raise
return False
except OSError as exception:
print("ERROR #" + str(exception.errno) + "IN makedirs")
raise
return False
print("" + get_timestamp() + " " + "Created folder: " + s_path + "")

def create_folders(
s_folder_path_template:str="",
i_from_count:int=1,
i_to_count:int=0
):
i_count=0
for i_loop in range(i_from_count, i_to_count + 1): 
create_folder(s_folder_path_template.format(count=i_loop))
i_count += 1

return i_count

def main():
options_dict = get_default_options()
exit_if_wrong_python_version(options_dict["s_for_python_version"])


print("+++")
print("" + get_timestamp() + " " + get_script_filename() + " started.")

i_total_created = create_folders(
options_dict["s_folder_path_template"],
options_dict["i_from_count"],
options_dict["i_to_count"])

print("" + get_timestamp() + " " + str(i_total_created) + " folders 
created.")
print("" + get_timestamp() + " " + get_script_filename() + " finished.")

if __name__ == '__main__': 
main()
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: i'm a python newbie & wrote my first script, can someone critique it?

2016-06-12 Thread mad scientist jr
Thanks for your reply!

On Saturday, June 11, 2016 at 2:41:39 PM UTC-4, MRAB wrote:
> Drop the next 3 comment lines. They add visual clutter, and no useful info.
> > ###
> > # REFERENCE MODULES
> > ###

I'm not going to argue minor points at length, because others have said the 
same thing here, but I will push back a little and explain that what you guys 
consider visual clutter, I find helps me to visually break up and quickly 
identify sections in my code, which is why I like those separators.

> There's an easier to make the repeated string: "+" * 79
> > 
> > print("+++")

Thanks, that's a good tip. In this case I might prefer showing the full line of 
+s because that way, wysiwyg, it's just easier to visualize the output.

Thanks again for the input. . . I will further digest what you all said and 
study some more (including the docstrings)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Set/Get attribute syntatic sugar

2005-06-28 Thread Gary Wilson Jr
Заур Шибзухов wrote:
> There is a syntactic sugar for item access in
> dictionaries and sequences:
> 
> o[e] = v <-> o.__setitem__(e, v)
> o[e] <-> o.__getitem__(e)
> 
> where e is an expression.
> 
> There is no similar way for set/get attribute for objects.
> If e is a given name, then 
>  
> o.e = v <-> o.__setattr__(e, v)
> o.e <-> o.__getattr__(e)
> 
> Anybody thought about this issue?

How about inheriting the dict class, something like this...

>>> class C(dict):
... pass
...
>>> e = 'myAttribute'
>>> v = 'syntactic sugar'
>>> o = C()
>>> o[e] = v
>>> o[e]
'syntactic sugar'

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

Re: Cleaning strings with Regular Expressions

2005-09-08 Thread Gary Wilson Jr
sheffdog wrote:
> Using regular expressions, the best I can do so far is using the re.sub
> command but it still takes two lines. Can I do this in one line? Or
> should I be approaching this differently? All I want to end up with is
> the file name "ppbhat.tga".

A regular expression to do what you want:
 >>> s = 'setAttr ".ftn" -type "string" 
 >>> /assets/chars/boya/geo/textures/lod1/ppbhat.tga";'
 >>> s = re.sub(r".*/(.*\.tga).*", r"\1", s)
 >>> s
'ppbhat.tga'

Is a regular expression the best solution?
That depends on what else you need to do with your data file.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: My First Python Script

2005-09-16 Thread Gary Wilson Jr
Ed Hotchkiss wrote:
> def ZeroThrough255():
>   x = 0
>   while x <= 255:
>   if len(x) == 1:
>   mySet = '00' + str(x)
>   elif len(x) == 2:
>   mySet = '0' + str(x)
>   else:
>   mySet = x
>   print mySet
>   x +=1   
> 
> ZeroThrough255()

Instead of using the while loop and a counter, you can use the range() 
function.  Using range() and string formatting you could to something like:

def ZeroThrough255():
for num in range(256):
print "%03d" % num

which, using a list comprehension and the string join() function, could also 
be written as:

def ZeroThrough255():
print "\n".join(["%03d" % num for num in range(256)])
-- 
http://mail.python.org/mailman/listinfo/python-list


.split() Qeustion

2013-08-16 Thread Alfonso Andalon Jr.

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


Re: semicolon at end of python's statements

2013-08-29 Thread Sam Fourman Jr.
On Wed, Aug 28, 2013 at 8:18 PM, Mohsen Pahlevanzadeh <
[email protected]> wrote:

> Dear all,
>
> I'm C++ programmer and unfortunately put semicolon at end of my
> statements in python.
>
> Quesion:
> What's really defferences between putting semicolon and don't put?
>
> Yours,
> Mohsen


I totally understand where you are coming from, but
I have found that the thing I can't get used to is the "indent thing"

Python is a great language, but I always secretly find myself
wishing I could somehow use python, and not deal with the mandatory
"indents"


Sam Fourman Jr.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Moving to Python for web

2013-08-29 Thread Sam Fourman Jr.
On Wed, Aug 28, 2013 at 4:14 PM,  wrote:

> So, I have been working in PHP for several years but I want to learn
> something new. That something new is Python. But since I'm a web developer
> I want to build stuff for the web.
>
> I don't want to use Django because it's too bloated, it seem to do
> everything for you. I don't like that. I want to do the "plumbing". But at
> the same time I have no idea how I would write something that could handle
> cookies, sessions, post, get etc etc; so I assume I have to use some kind
> of web framework.
>
> So, can you recommend a minimal web framework that still allows me to
> write in Python? Furthermore, do I even need one? I am currently running
> NGINX and I have UWSGI installed. I'm just worried about how I would handle
> form submissions, get requests and sessions/cookies.
>
> Any advice would be greatly appreciated.
> --
> http://mail.python.org/mailman/listinfo/python-list
>


I am in the same boat as you, I need to rid myself of php, and ruby doesn't
"feel" right..
I like python for system admin stuff.. it seems everything has python
bindings :)

there are MANY micro frameworks, I have been following these guys for a few
years
http://www.pocoo.org/

specifically jinja2 and flask looks to be the best choice out of all the
options out there

-- 

Sam Fourman Jr.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: basic maze problem with turtle

2013-10-14 Thread Sam Fourman Jr.
On Sun, Oct 13, 2013 at 11:44 PM, Gary Herron <
[email protected]> wrote:

> On 10/13/2013 03:03 PM, Denis McMahon wrote:
>
>> Except perhaps Nikos. Nikos can probably write you extremely elegant one
>> line python solutions to any coding problem you describe to him. His
>> solutions might suffer the very minor flaw of not working, but they're
>> guaranteed to be Nikos certified aesthetically pure, and hence far
>> superior to any solution more mundane coders might produce.
>>
>
> That was uncalled for.   There is already too much Nikos-bashing and
> Nikos-basher-bashing (and so on) in this newsgroup without dredging up even
> more in this completely unrelated request.
>
> Gary Herron
>
>
> --
> https://mail.python.org/**mailman/listinfo/python-list<https://mail.python.org/mailman/listinfo/python-list>
>

Who the hell is Nikos? I hear reference to this guy ALL the time, is he a
troll or a python god?
this simply isn't clear.. I have only been on this list a few months.

-- 

Sam Fourman Jr.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: GO vs Python

2014-08-24 Thread Sam Fourman Jr.
On Sun, Aug 24, 2014 at 9:36 PM, Rodrick Brown 
wrote:

> I spent a few weeks looking at Go and have to say you can see a lot of
> Python's influence in Go, however my question to this list for others who
> are doing real work with Go and Python have you encountered any scenarios
> in which Go outmatched Python in terms of elegance or performance?
>
> --RB
>


I use both, Python pays the bills, and I use it at work or on consulting
gigs.
for most things GO is faster, GO is compiled and that is a huge plus.

the Go community is not nearly as large as pythons, there are loads more
libraries and tools for python

my initial reason for even looking at GO, was because, I noticed that if I
wanted to move my largest clients app from Python 2.x to 3.x it was almost
a rewrite. and then when I noticed the libraries for python 3.x were
limited, and some python 2.x libraries are not even making a 3.x version...

Well I got scared, Go started to look attractive, because your no longer
comparing GO to the entire python community, it is GO vs python 3...


thats just my 2 cents, I like python and it pays my bills... but I hate the
way python delt with the 2.x - 3.x, they dropped the ball.

-- 

Sam Fourman Jr.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: GO vs Python

2014-08-24 Thread Sam Fourman Jr.
On Sun, Aug 24, 2014 at 10:07 PM, Chris Angelico  wrote:

> On Mon, Aug 25, 2014 at 12:57 PM, Sam Fourman Jr. 
> wrote:
> > my initial reason for even looking at GO, was because, I noticed that if
> I
> > wanted to move my largest clients app from Python 2.x to 3.x it was
> almost a
> > rewrite. and then when I noticed the libraries for python 3.x were
> > limited, and some python 2.x libraries are not even making a 3.x
> version...
> >
> > Well I got scared, Go started to look attractive, because your no longer
> > comparing GO to the entire python community, it is GO vs python 3...
>
> If your Python 2 -> Python 3 transition was "almost a rewrite", then
> either your code is making horribly messy assumptions about bytes vs
> text everywhere (in which case the pain will happen, Py3 just forces
> you to deal with it up-front instead of burying your head in the sand
> and wishing "funny characters" would go away), or you did the
> transition wrongly. It's not a complete change of language.
>
> And, what libraries are you short of for Python 3? List them! Maybe
> they do exist now. Nearly everything important does, there are only a
> handful of large/popular 2.x-only modules. And if you talk about
> what's missing, you demonstrate the need for those ports, which might
> be the impetus someone needs to make it available.
>
> There's way too much vague FUD about Python 3. Everyone who complains
> does so with "oh, there aren't many libraries for Python 3", not with
> "PyFooBar isn't available for Python 3", which would actually be
> useful.
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>

Thanks your your input chris, honestly it was the end of 2012 when I looked
into a large py3 port for a client.
I wrote a very large web project on Cheetah, and at the time there wasnt a
Py3 port... Now I get that back when I wrote this code years before, I
should have chose something else..

I remember doing some browsing around, and the pooco people that make
jinja2 were not fans of python3(I forget the blog post), I got scared
because a very large portion of my income was based on a single client...
So since we were having scalability issues anyway, I moved them to GO, and
it was a Win - Win, the GO standard lib does so much, and the scalability
gains we received over python were so large, that we were able to reduce
out AWS bill so much that I could hire another coder.

I really like python, and we use it a ton, but a python like compiled
language did wonders for us when we needed it most.

Sam Fourman Jr.

-- 

Sam Fourman Jr.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: help a newbie with a IDE/book combination

2006-07-12 Thread Ron Rogers Jr.
On 9 Jul 2006 16:42:27 -0700
[EMAIL PROTECTED] wrote:

> Hi,
> 
> I already have a couple of newbie books on Python itself, but
> would rather get started with a nice to use IDE and I am
> therefore looking for a good IDE to learn Python. 
> 
> Is there a good IDE which would be well documented out there?


Python comes with IDLE.  It should be in /usr/local/bin

If not try:

python2.4 /usr/local/lib/python2.4/idlelib/idle.py

I like idle as a beginner because it's easy for me to test out
my simple little learning scripts while in it. (though I figure
there's probably a way to do that from within vim or emacs)

As some suggested, as a beginner you don't need much of a super
powered IDE.  If I wasn't using IDLE, I'd be using vim or gvim.


CronoCloud (Ron Rogers Jr.)


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


Re: first book about python

2006-07-12 Thread Ron Rogers Jr.
On Sun, 09 Jul 2006 03:41:52 +0300
IOANNIS MANOLOUDIS <[EMAIL PROTECTED]> wrote:

> I want to learn python.
I am looking for a book which will help
> me get started and should contain the foundations. I am not
> looking for the Python bible. Any recommendations?
> Ioannis
> 

Hmm, no one has mentioned Python Programming for the Absolute
Beginner (second edition) by Michael Dawson.
http://www.amazon.com/gp/product/1598631128/102-5443736-1342538?v=glance&n=283155

Yes, it's very game oriented, but it's also very newbie oriented.

I've slso downloaded some Python tutorials:

I've got the Python version of How to Think Like a Computer
Scientist:

http://www.ibiblio.org/obp/thinkCSpy/

And Dive into Python (available online as well as paper):

http://diveintopython.org/

Hope this helps.

CronoCloud (Ron Rogers Jr.)




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


Python to log into web site

2006-07-18 Thread david brochu jr
Hi,
 
I have been browsing around the net looking for a way (hopefully an easily implemented module) to log into a web site using python. The site I wish to log into is an internal site which requires email address and password for authentication. Does anyone have any suggestions or links that might point me in the right direction?

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

PAMIE error help needed

2006-07-19 Thread david brochu jr
I have thrown together a script which reads a list or urls from a txt file and navigates to each url while recording how long it takes for the page to render completely using PAMIE. For some reason I randomly get crashes reporting: 

 

  File "c:\Python24\scripts\PAM.py", line 30, in IE_Invoke    ie.Navigate(url)  File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line 496, in__getattr__    raise AttributeError, "%s.%s" % (self._username_, attr)
AttributeError: InternetExplorer.Application.Navigate
The code I use to browse through the list;
for x in f:    ie = IE_Invoke(x)    starttime = time.clock()   #get timestamp at IE startup    wait(ie) #wait for IE to completetly load page    stoptime = time.clock()#get timestamp at IE completion
    elapsed = stoptime-starttime   #calculate the runtime    ie.QUIT()    excel_open.xlApp.ActiveSheet.Cells(Row,1).Value = x excel_open.xlApp.ActiveSheet.Cells(Row,2).Value = elapsed
        Row = Row+1    count_non_no_tool = count_non_no_tool + 1    total_non_no_tool = elapsed + total_non_no_tool 
 
    f = f.close()
 
The script crashes in different locations when it crashes so it doesn't appear to be one url causing the problem. Any ideas?
-- 
http://mail.python.org/mailman/listinfo/python-list

Automate Mozilla Firefox

2006-07-26 Thread david brochu jr
Hey everyone,I am trying to automate navigating to urls (all from a txt file) 1 at a time in Firefox and then killing firefox before navigating to the next. I think I might have to use PyXPCOM to do this but I have never used this package and cannot find any good resources on the net to help me along. Anyone have an idea as to how I would do this or have any good resources they could point me to?
Thanks
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Automate Mozilla Firefox

2006-07-26 Thread david brochu jr
 want to take a text file (which has a list of urls) and have my script go through them 1 by one using Firefox. 
 
So for instance, if the first two urls in my list were: 
www.google.com
www.amazon.com
 
I would want to spawn firefox and load www.google.com. Once google loads, I would like to kill Firefox and restart it, this time with 
www.amazon.com loaded. I am basically running a stress test on a browser based product.

 
I have been able to do this in IE with no problems (Calling IE's COM object).I also have used the PAMIE module without a problem in IE. The problem is Firefox uses XPCOM and I have never worked with XPCOM, and thus havent worked with PyXPCOM before. Any insight will help. 

 
FYI: I did try writing a script which loads firefox from the command line and navigates to a site, but once I try to kill Firefox and move to the next url nothing happens:
 
import os
import time
 
file = open("C:\urls.txt")
 
for x in file:
   
   firefox = "C:\progra~1\mozill~1\firefox.exe "
   firefox = firefox + x
   os.system(firefox)
   time.sleep(10)
   taskkill = "taskkill /f /im firefox.exe"
   os.system(taskkill)
 
file.close () 
-- 
http://mail.python.org/mailman/listinfo/python-list

can't kill os.system process

2006-07-27 Thread david brochu jr
When I run the following code:
 
import os
 
file = "C:\\progra~1\\mozill~1\\firefox.exe www.google.com"
os.system(file)  # this will spawn Firefox and naviage to google.com
 
kill = "taskkill /f /im firefox.exe"
os.system(kill)  # this should kill Firefox instance that was just spawned
 
 
 
the script never gets to kill the insance of firefox. When I manually close Firefox, my cmd window indicates that the taskkill command was unsuccessful, which leads me to believe that after I open Firefox the system is not getting any indication that the command finished executing, which would result in Firefox not being killed. I also tried substituting "
os.system" with "os.popen" which did the same thing.
 
Anyone have an idea how I can kill the instance of Firefox?
 
-- 
http://mail.python.org/mailman/listinfo/python-list

Automate logging into page

2006-08-11 Thread david brochu jr
I am trying to automate logging a website and have been unsuccessful. The code below is supposed to log me into the site, but changing the username/password to an incorrect combination does not cause an error or crash to be seen. My goal is to log into this page and save the cookie from the page so that when I spawn IE and navigate to this site I will be logged in. I am using the urllib2 module. Any suggestions? 
import urllibimport urllib2url = ''values = {'id_l_email': 'X', 'id_l_password':'X'}data = "">req = urllib2.Request(url,data)response = urllib2.urlopen(req)the_page = response.read()
-- 
http://mail.python.org/mailman/listinfo/python-list

Need array help

2006-10-06 Thread Marion Long Jr
I am switching from microsoft visual basic programming to python 
programming. In microsoft
visual basic you can Dim a variable so that you can add variables by 
changing the number
on the end of the variable as in the following example;

Dim acct(100)

numoffiles=4
data=10
ct=1
while ct <> numoffiles
acctfile(ct) = data
ct= ct + 1
data= data + ct
Wend
The results are;
acctfile(1)=10
acctfile(2)=12
acctfile(3)=15

And you can compare the values of the new variables;
if acctfile(1) > acctfile(2) then print "yes"
if acctfile(2) > acctfile(1) then print "yes"

when I try to create acctfile(ct) = data I get the following error;
***can't assign to function call. Then it gives the program line of the 
problem
Here is the progam in python;

numoffiles=4
data=10
ct=1

while ct != numoffiles:
acctfile(ct) =data
ct += 1
data= data + ct
print acctfile(ct)

Does anybody know how this is done in Python? 


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


Tkinter question

2006-05-31 Thread david brochu jr
I am trying to create a GUI that will display a new window with information about my program when the user clicks on the info button (a green "i" bitmap). So far all I can get my program to do is show the new window (using Toplevel() ) when the program loads, not when the user presses the information bitmap. I think it has something to do with my command for the information button. Anyone have any ideas or have a GOOD resource that they could point me to?

 
Thanks
 

from Tkinter import *
class Application(Frame):  """ A GUI application with three buttons. """    def __init__(self, master):    """ Initialize the Frame. """    Frame.__init__(self,master)
    self.grid()    self.create_widgets()     def update_text(self):    message = self.toolbar.get()    self.results.delete(0.0, END)    self.results.insert(0.0, message)      def create_widgets(self):
    # create variable for single toolbar selection    self.toolbar = StringVar()        """Create button, text and entry widgets. """    #create welcome text    welcome = Label(self)
    welcome["text"] = "You are now about to run Automation Testing.\n"\    "Please check the toolbar to be tested and then select\n"\    "the test you would like to perform."
        welcome.grid(row = 0, column = 0, columnspan = 3, sticky = W)        #create Upr Radio    Radiobutton(self, text = "Upr", variable = self.toolbar,    value = "upr", command = 
self.update_text).grid(row = 1, column = 0, sticky = W)        #create Com Radio    Radiobutton(self, text = "Com", variable = self.toolbar,    value = "com", command = self.update_text
).grid(row = 1, column = 1, sticky = W)        #create CI Radio    Radiobutton(self, text = "CI", variable = self.toolbar,    value = "ci", command = self.update_text).grid(row = 1, column = 2, sticky = W)
        #create text box    self.results = Text(self, width = 40, height = 4, wrap = WORD)    self.results.grid(row = 2, column = 0, columnspan = 3, sticky = W)            #create Performance button
    self.perf_bttn = Button(self)    self.perf_bttn["text"] = "Performance"    self.perf_bttn["command"] = self.perf    self.perf_bttn.grid(row = 3, column = 0, sticky = W) 
    message = self.toolbar.get()        #create PII button    self.pii_bttn = Button(self)    self.pii_bttn["text"] = "PII"    self.pii_bttn.grid(row = 3, column = 1, sticky = W)
        #create info button    self.info_bttn = Button(self)    self.info_bttn["fg"] = "green"    self.info_bttn["bitmap"] = "info"    self.info_bttn.command = self.info
()    self.info_bttn.grid(row = 3, column = 2, sticky = W)        #create exit button    self.exit_bttn = Button(self)    self.exit_bttn["fg"] = "red"    self.exit_bttn["cursor"] = "pirate"
    self.exit_bttn["text"] = "EXIT"    self.exit_bttn["command"] = root.quit    self.exit_bttn.grid(row = 3, column = 3, sticky = W)    def perf(self):    import performance
    performance.perf(self.toolbar.get())
      def info(self):    # create child window     win = Toplevel()                  # mainroot = Tk()root.title("Automation Testing")app = Application(root)
root.mainloop()
-- 
http://mail.python.org/mailman/listinfo/python-list

Tkinter

2006-06-02 Thread david brochu jr
Does anyone know how to get the value of the file selected when using tk_getOpenFile in Tkinter?
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Starting New Process

2006-06-05 Thread david brochu jr
try os.spawn() using the os module
-- 
http://mail.python.org/mailman/listinfo/python-list

RSS feeds

2006-06-06 Thread david brochu jr
Not sure where to post this one so here it goes...sorry to anyone if it shouldnt be here.
 
I am looking to take RSS feeds a process them with a python program..any idea where I can get RSS feeds for sports stats, and how I would use the script to connect automatically to the feed?
-- 
http://mail.python.org/mailman/listinfo/python-list

newbe: tuple

2006-06-14 Thread david brochu jr
I am trying to get my ip address through a script and I am using the following code:
 
import socket
 
ip = socket.gethostbyaddr(socket.gethostname())
 
 
 
ip then becomes a tuple and takes on three values. I am trying to pull the value of ip[2] which when printed displays:
['10.5.100.17'].
 
I want this ip that is being returned, but I would like it as a string, without the [' and ']. Any idea how I would trim this down?
 
 
-- 
http://mail.python.org/mailman/listinfo/python-list

wait for keystoke

2006-08-30 Thread david brochu jr
I want to add a "press any key to continue" option to my script, where the script pauses until the users presses any key. Does anyone know how I would do this without having to add in an if statement in the middle of my existing script? Is there a method already to accomplish this?

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

Re: Ensure a variable is divisible by 4

2006-12-05 Thread david brochu jr

You can use the modulous "%" to check for a remainder of division. If no
remainder is found you know the number is divisible by 4.

Ex:

x = 111

if x%4 == 0:
  print "X is divisible by 4"

-- Forwarded message --
From: "John Machin" <[EMAIL PROTECTED]>
To: [email protected]
Date: 5 Dec 2006 11:26:49 -0800
Subject: Re: Ensure a variable is divisible by 4

Paul Rudin wrote:

Max M <[EMAIL PROTECTED]> writes:

> [EMAIL PROTECTED] skrev:
>> Nick Craig-Wood wrote:
>>> [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
  I am sure this is a basic math issue, but is there a better way to
  ensure an int variable is divisible by 4 than by doing the

following;


  x = 111
  x = (x /4) * 4
>
> X *= 4
>
> ;-)
>


x=4

:)


Ensure x is divisible by *any* non-zero integer:

x = 0

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

PyCon 07

2006-12-07 Thread david brochu jr

Anyone able to register yet for PyCon07? I can't find any link online..I
want to get in early to lock in on the cheaper registration rate..any ideas?
-- 
http://mail.python.org/mailman/listinfo/python-list

trying to use swig for the first time

2006-01-23 Thread Gary Wilson Jr
...I have some C code (foo.c and foo.h) that I would like to be able to access 
using python.

I've written my interface file (foo.i) like so:
%module foo
%{
#include "foo.h"
%}
%include "foo.h"

I then do the following on the command line:
$ swig -python foo.i
$ gcc -c foo.c foo_wrap.c -I /usr/include/python2.4
$ ld -shared foo.o foo_wrap.o -o _foo.so

Then when I try importing the module into python:
$ python -c "import foo"
Traceback (most recent call last):
   File "", line 1, in ?
   File "foo.py", line 5, in ?
 import _foo
ImportError: ./_foo.so: undefined symbol: EVP_DecodeBlock

Now, EVP_DecodeBlock can be found in /usr/include/openssl/evp.h:
int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n);

And evp.h in included in foo.h:
#include 

What am I doing wrong here?
Do I need to include more in the interface file?

I tried adding the EVP_DecodeBlock declaration to the interface file like so:
%module foo
%{
#include "foo.h"
extern int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n);
%}
%include "foo.h"
extern int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n);

But this led to the exact same error when trying to import the python module.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: beta.python.org content

2006-01-28 Thread Ron Rogers Jr.
Steve Holden wrote:
> How does
> 
>   http://beta.python.org/about/beginners/
> 
> look?
> 
> regards
>  Steve

Hi, I'm an actualy Python beginner, decided recently to "play" with 
Python.  I'm a "user", not a professional programmer or developer of any 
sort, so I guess the "beginner's" page would be aimed at folks like me.

It looks fine, degrades pretty well in Dillo.

But.it needs more Beginners links and info.  The "Why Python" seems 
a bit out of place, more akin to something that would be on the beta 
home, which looks a little "corporate brochure site" to me.  It also 
seems a little "bland" as a beginner site goes. A little bit of "fun" 
and "friendliness" in the spirit of "Python for Everyone" might be 
something to add.  That's what brought me to Python.  The idea that 
Python was not just for people like ESR who've been programmers for 
decades, or for corporate types designing applications containing a new 
paradigm of competencies in objective oriented programming, but for high 
school students, hobbyist programmers and even those who've never 
written a line of code in their lives.

It has been suggested that a Google-like hierarchy might be useful and I 
agree, though I don't know how that might work in practice. You could 
have a bland "brochure" site with the proper buzzwords for the 
corporates, another for the devs with late breaking patches, news, RSS 
feeds, whatever they need. and one for Education and/or beginners, with 
perhaps a colorful friendly look. (but perhaps keeping the same basic 
overall base look)

I actually like the look of the current http://www.python.org  It packs 
a lot of useful links in one page and it seems "friendly"  Which 
probably sounds silly to describe an emotional reaction or "feel" to a 
site. Admittedly it doesn't look "corporate" or "slick professional" but 
that's not necessarily a bad thing.

I agree with others about the new logo. It lacks a certain, pardon the 
expression, "je ne sais quoi". (one of the things that got me interested 
in Linux was seeing that penguin associated with the word "Linux" and 
making me curious about what that Linux thing was all about)  But it 
would make a good logo for a "enterprise.python.org" 
"business.python.org"  So perhaps different logos for different purposes?

A cartoony friendly python in front of a blackboard for education 
(similar to the Pygame python)

A python reading a book at the base of a larch for a listing of books

That sort of thing.

The python.org site's been useful to me, pointing me to interesting 
software, documentation and whatnot. Though I didn't know about IDLE 
until I saw it mentioned in a post on Slashdot in a story asking for 
recommendations for Python IDE's.  I am "very" new to Python.


CronoCloud (Ron Rogers Jr.)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: problems with documentation

2006-01-28 Thread Ron Rogers Jr.
BartlebyScrivener wrote:
> Specifically it's the TOPICS that I can't seem to get to work. The
> keywords and modules etc do work. But if I type, e.g.,
> help("functions") it says, "No documentation found" If I type
> help("os") I get help on the os module.
> 
> rpd
> 

The TOPICS seem to be case sensitve so

help> assertion

would not work, but

help> ASSERTION

will.


Just figured this out myself, yesterday.


CronoCloud (Ron Rogers Jr.)
-- 
http://mail.python.org/mailman/listinfo/python-list


Needing a WinXP Python variant of a line of code

2006-01-30 Thread Ron Rogers Jr.
I have this line of code that's written with Linux in mind:

path_to_nethack_logfile = os.popen("locate logfile | grep 
nethackdir").read()

and I'm wanting a Windows equivalent, any suestions?


Thanks.

CronoCloud (Ron Rogers Jr.)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Needing a WinXP Python variant of a line of code

2006-01-30 Thread Ron Rogers Jr.
Tim Golden wrote:
> [Ron Rogers Jr.]
> 
> | I have this line of code that's written with Linux in mind:
> | 
> | path_to_nethack_logfile = os.popen("locate logfile | grep 
> | nethackdir").read()
> | 
> | and I'm wanting a Windows equivalent, any suestions?
> 
> Well, you could obviously use os.walk to write something 
> (cross-platform) which would search the entire filesystem 
> for a filename matching the pattern you're after.
> 

Thank you.  I'm very new to Python, only bought my first book in the 
last couple of weeks, and hadn't read about os.walk yet.

> But there's no universal Windows equivalent to the Unix
> locate database. More recent Wins do offer you the system
> indexing catalog (or whatever it's called) and I'm sure
> there are existing apps to do the same sort of thing with
> more or less flair and automation, but there's nothing
> which is guaranteed to be there.

Ah... I thought that perhaps there was a built in command line tool that 
does what that "search dog" does.that I didn't know about.  I am not as 
familiar with the Windows command prompt as I probably should be.

Thanks again.


CronoCloud (Ron Rogers Jr.)


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


Re: Needing a WinXP Python variant of a line of code

2006-01-30 Thread Ron Rogers Jr.
John Zenger wrote:
> import os, os.path
> 
> path_to_nethack_logfile = ""
> for root, dirs, files in os.walk("c:\\"):
> if 'nethackdir' in root:
> logs = [x for x in files if 'logfile' in x]
> if len(logs) > 0:
> path_to_nethack_logfile = os.path.join(root, logs[0])
> exit
> 

Thank you.  I guess I should do more reading, since I hadn't read about 
os.walk yet. I shouldn't even be trying to do what I'm doing so early in 
my learning. It will eventually be a Nethack logfile parse script.


CronoCloud (Ron Rogers Jr.)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Learning Python

2006-02-06 Thread Ron Rogers Jr.
Byte wrote:
> Yes, sorry, didnt realise diffrence between int and input. Since i'm
> such an idiot at this, any links to sites for people who need an
> unessicerily gentle learning curve?
> 

I'm new to Python too, here's a few I've found useful:

http://www.greenteapress.com/thinkpython/

http://wiki.python.org/moin/BeginnersGuide/NonProgrammers

Python Programming for the Absolute Beginner by Michael Dawson. It is 
the book I'm using. It's different from other Python books in that it's 
examples/sample programs are games or game related.  The author uses a 
modified version of the LiveWires modules later in the book along side 
Pygame

http://www.amazon.com/gp/product/1598631128/002-1529099-9424031?v=glance&n=283155

(That's the second edtion, no reviews yet.)

http://www.amazon.com/gp/product/1592000738/002-1529099-9424031?v=glance&n=283155

(first edition with reviews)

LiveWires they've got materials to go with their modules.

http://www.livewires.org.uk/python/

You haven't mentioned using IDLE, the built in IDE, I have found it useful:

http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/index.html

It might not be in your menus though, on my box it's at:

python2.4 /usr/local/lib/python2.4/idlelib/idle.py


CronoCloud (Ron Rogers Jr.)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Convert from numbers to letters

2005-05-19 Thread Gary Wilson Jr
Bill Mill wrote:
> On 5/19/05, Peter Otten <[EMAIL PROTECTED]> wrote:
> 
>>Bill Mill wrote:
>>
>>
Traceback (most recent call last):
File"",line1,in?
NameError: name 'sorted' is not defined

I think you're probably using 2.4 ??
>>>
>>>Yes, sorted() is new in python 2.4 .You could use a very lightly
>>>tested pure-python partial replacement:
>>
>>By the way, sorted() can be removed from your original post.
>>
>>Code has no effect :-)
> 
> 
> I'm gonna go ahead and disagree with you:

Me too, although I would forgo the sort altogether (while making things
a little more readable IMO):

> alpha = 'abcdefghijklmnopqrstuvwxyz'.upper()
> pairs = [''.join((x,y)) for x in alpha for y in [''] + [z for z in alpha]]
> pairs = sorted(pairs, key=len)

alpha = 'abcdefghijklmnopqrstuvwxyz'.upper()
pairs = [x for x in alpha] + [''.join((x,y)) for x in alpha for y in alpha]



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


Re: Convert from numbers to letters

2005-05-19 Thread Gary Wilson Jr
Gary Wilson Jr wrote:
> alpha = 'abcdefghijklmnopqrstuvwxyz'.upper()
> pairs = [x for x in alpha] + [''.join((x,y)) for x in alpha for y in alpha]

I forget, is string concatenation with '+' just as fast as join()
now (because that would look even nicer)?
-- 
http://mail.python.org/mailman/listinfo/python-list


PAM authentication?

2005-05-24 Thread Gary Wilson Jr
I would like my application to be able to authenticate through PAM. Is
there any code out there that implements this? All I could find was PyPAM
(http://www.pangalactic.org/PyPAM/), which doesn't look like it has been
touched in almost 6 years and requires python1.5.

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


__init__.py in packages

2005-06-08 Thread Gary Wilson Jr
I'm creating a python package foo.

What is intended use for __init__.py files?
Well, I found this: http://www.python.org/doc/essays/packages.html
>From what I can gather it is for initialization of the package when doing an
import, but I would really like to see an example or situation that makes good
use of the __init__.py file.

Looking at the distutils __init__.py file, it only defines things like
__version__.  However, looking at the logging __init__.py file, it is a
1196-line monster with functions and classes defined throughout.

What is the RightThing?

Should I only define things in __init__.py that need to be defined when
importing a subpackage and/or module of package foo?

Is it ok for me to define classes in foo/__init__.py?
Whereby I could do something like:

from foo import MyClass

Or is is better if I were to put these classes and/or functions in foo/core.py?
Whereby I would do something like:

from foo.core import MyClass
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Perl s/ To Python?

2005-06-10 Thread Gary Wilson Jr
John Abel wrote:
> Does anyone know of a quick way of performing this:
> 
> $testVar =~ s#/mail/.*$##g

Use the re (regular expression) module.  Since you are iterating over a lot of
entries, it is good to compile the regular expression outside of the loop.

>>> import re
>>> mailRE = re.compile('/mail/.*$')
>>>
>>> myList = ['/var/mail/joe', '/var/spool/mail/bob']
>>> remainderList = []
>>>
>>> for testVar in myList:
... remainderList.append(mailRE.sub('', testVar))
...
>>> print '\n'.join(remainderList)
/var
/var/spool


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


Re: Using Excel With Python

2007-01-11 Thread david brochu jr

Try using ExcelApp.Close(). This should kill the entire application (it
might prompt for a Save).
-- 
http://mail.python.org/mailman/listinfo/python-list

Tail a file

2006-04-20 Thread david brochu jr
Hello,
 
I wrote a script to monitor ping activity and output it to a log file. I am using windows and want to have another script constantly check the latest entry to see if Request timed out is seen. Is there a way to "tail" a file much like I would in Unix so I can just see the latest entry and move from there?

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

tail a file (win)

2006-04-20 Thread david brochu jr
Hello,
 
I wrote a script to monitor ping activity and output it to a log file. I am using windows and want to have another script constantly check the latest entry to see if Request timed out is seen. Is there a way to "tail" a file much like I would in Unix so I can just see the latest entry and move from there? 

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

search a string

2006-04-20 Thread david brochu jr
Hello,
 
 
I have a text file with the following string:
['\r\n', 'Pinging www.ebayyy.com [207.189.104.86] with 32 bytes of data:\r\n', '\r\n', 'Request timed out.\r\n', '\r\n', 'Ping statistics for 
207.189.104.86:\r\n', '    Packets: Sent = 1, Received = 0, Lost = 1 (100% loss),\r\n']
 
 
How would I search to find out if the string contained "Request" and report if "Request" was found or not in the string?
-- 
http://mail.python.org/mailman/listinfo/python-list

search files in a directory

2006-04-20 Thread david brochu jr
Hello,
 
I need to open every file in a directory and search for a string. What module is needed to do this and how would I go about searching each file?
-- 
http://mail.python.org/mailman/listinfo/python-list

detect enter key

2006-04-28 Thread david brochu jr
I am writing a script in which I need to wait for the user to press enter before continuing...how would I detect when the user presses the "Enter" key?
 
 
Thanks
-- 
http://mail.python.org/mailman/listinfo/python-list

making IE toolbars visible

2006-05-02 Thread david brochu jr
Anyone know how if there is a module out there or some way to automate making an IE toolbar visible in IE?
 
 
Thanks,
Dave
-- 
http://mail.python.org/mailman/listinfo/python-list

PAMIE syntax

2006-03-09 Thread david brochu jr
Hi everyone,
 
I am trying to automate Internet Explorer and am trying to use the PAMIE module for Python2.4. So far I have been unable to find any documentation online which provides syntax for using thie module. For instance, does anyone know how to use PAMIE to close a browser instance?

 
 
Any info you have would be great!
-- 
http://mail.python.org/mailman/listinfo/python-list

Excel Object Model

2006-03-10 Thread david brochu jr
Hello,
 
I am trying to automate Excel and I cant seem to find out much relating to it's object model (in relation to Python)..seems as if its mostly covered by C and VB. Can anyone point me in the right direction? I am able to open excel, add information to cells, and then save and close the book opened. I was looking to get into formatting of cells, formulas, etc.

 
Below is the code i have now...any responces would help.
 

import PAMimport timefrom win32com.client import Dispatch    #this is needed to open an Excel fileexecfile('c:\\Python24\\scripts\\PAM.py')f = open('c:\python24\scripts\urls.txt','r')  #opens list of urls to be tested
xlApp = Dispatch("Excel.Application")xlApp.Visible = 0xlApp.Workbooks.Add()Row = 1
for x in f:  #run this for every url in txt file. ie = IE_Invoke(x) starttime = time.clock()   #get timestamp at IE startup wait(ie) #wait for IE to completetly load page stoptime = time.clock()#get timestamp at IE completion
 elapsed = stoptime-starttime   #calculate the runtime ie.QUIT() xlApp.ActiveSheet.Cells(Row,1).Value = x  xlApp.ActiveWorkbook.ActiveSheet.Cells(Row,2).Value = elapsed Row = Row+1
xlApp.ActiveWorkbook.ActiveSheet.SaveAs('c:\\test_results\dave.xls') #save results to excel bookxlApp.Quit()  
-- 
http://mail.python.org/mailman/listinfo/python-list

Clearing IE history

2006-03-15 Thread david brochu jr
Hello
 
I am trying to automate the clearing of IE history using python but keep running into problems. I cannot seem to find a good resource online about this, and I can't find an object in InternetExplorer's object module to point me in the right direction. I would rather not have to deal with deleting a bunch of registry values and keys or paths to do this, as this script will be run on numerous machines.

 
Anyone have any ideas?
-- 
http://mail.python.org/mailman/listinfo/python-list

Popen

2006-03-30 Thread david brochu jr
I am trying to write a script that starts a window process and then continues on to do other testing, but have encountered a little problem. When I start the exe (process to run) I cannot move on past that point in my script. Once started, the process is supposed to run in the background continuously and this is the reason my script stalls after starting the process. I have tried to initiate the process using 
os.system and os.popen and both run into the same problem. Is there a work around for this?
 
Thanks,
Dave
-- 
http://mail.python.org/mailman/listinfo/python-list

Spawn/Kill Process

2006-03-31 Thread david brochu jr
I need to write a script that starts an exe and then continues throughthe script. I am able to start the exe file but my script doesn'tcontinue because the process I start runs in the background of Windows(as it is supposed to). I have tried using both 
os.system and os.popento get around this but still no luck. It seems as if Python does notmove to the next line of code UNTIL the program spawned completes(which this one never will as it is supposed to continuously run in
the background). Does anyone know of a way around this so I can spawnthe program and continue through my script?
-- 
http://mail.python.org/mailman/listinfo/python-list

String Matching

2006-03-31 Thread david brochu jr
Hello,
 
I am trying to write a script that takes strings from a text file and searches to see if they are present in another text file...here is the code:
 
import osimport re

search = open("c:\python24\scripts\pii\expected_rules_results.txt")
def find(x): file = open("c:\python24\scripts\pii\dave.txt") regexp = re.compile(x) for line in file.readlines():  if regexp.search(line):   print "Found", x   break 
file.close()  
for x in search: find(x)search.close()
 
Unfortunately the strings I will be searching for contain numerous "*" that cause an error. For example, when try to search for:
http://www.widget.com/personal_firewall.csp/?pin={6}
I get the error message:
Traceback (most recent call last):  File "C:\Python24\scripts\PII\search    find(x)  File "C:\Python24\scripts\PII\search    regexp = re.compile(x)  File "C:\Python24\lib\sre.py", line
    return _compile(pattern, flags)  File "C:\Python24\lib\sre.py", line    raise error, v # invalid expressiosre_constants.error: multiple repeat
 
Anyone know how to get around this?
-- 
http://mail.python.org/mailman/listinfo/python-list

Regular Expressions

2006-04-12 Thread david brochu jr
Hi, 
 
I am trying to grab the following string out of a text file using regular _expression_ (re module):
 
"DcaVer"=dword:0640
 
What I need to do with that string is trim down " "DcaVer"=dword:" and convert the remaining number from hex to dec.
 
I have been trying to figure this out for a while..I am fairly new so please any help would be greatly appreciated.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Regular Expressions

2006-04-12 Thread david brochu jr
Pete,
Why do you have to use a regular _expression_?
I don't, I just though this was the easiest way.> "DcaVer"=dword:0640Is all your other input pretty much identical in form?  Specifically,the number of interest is the last thing on the line, and always
preceded by a colon? 
The other information is pretty much identical in form, yes. Exactally, all I am interested in is the number following the colon.
> What I need to do with that string is trim down " "DcaVer"=dword:" and> convert the remaining number from hex to dec.What does "trim down" mean?  Do you need something out of the string, or
are you just discarding/ignoring it?
 
What I meant was I want to discard the "DcaVer"=dword: . All I am interested in is searching for "DcaVer, finding it, and then taking the numerical value found after the colon.
s = '"DcaVer"=dword:0640'value = int(s.split(':')[-1], 16)(In other words, split on colons, take the last field and, treating itas a hex value, convert to an integer.)
 
The only problem with this is DcaVer's value is not always going to be the same, so I need to search specially for DcaVer and then after finding it get the numerical value associated with it. 
 
Thanks
-- 
http://mail.python.org/mailman/listinfo/python-list

Remove Whitespace

2006-04-13 Thread david brochu jr
Hi again,
 
Trying to remove whitespace from a string in a text file.
 
the string is:
D c a V e r " = d w o r d : 0 0 0 0 0 6 4 0
 
how would i go about doing this?
-- 
http://mail.python.org/mailman/listinfo/python-list

whitespace again

2006-04-14 Thread david brochu jr
hello again,
 
still having problemsi have the following in a txt file:
 

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\software\compete\dca]"UserId"="92005851""PanelId"="mayflower""PanelName"="Consumer Input Toolbar""CaptureType"=dword:0002
"CapTypOvr"=dword:0001"ExePath"="C:\\Program Files\\Consumer Input Toolbar\\ConsumerInputToolbar.exe""DcaVer"=dword:0640"DcaUpdateVer"=dword:0640
"CfgVer"=dword:0640"RulesVer"=dword:0008"UaCheck"=dword:005a"Survey"=dword:0001"ErrWaitMin"=dword:0001"ErrWaitMax"=dword:0002
"KeepAlive"=dword:0001"PerfEnabled"=dword:"PerfPath"="http://www.consumerinput.com.edgesuite.net/speedera/10k2.txt
"
I want to remove the "  found at the beginning of each line. When I use:
for line in new_line.readlines(): line = re.sub('"',"",line)  print line
I get: 
i n d o w s   R e g i s t r y   E d i t o r   V e r s i o n   5 . 0 0  
 
H K E Y _ L O C A L _ M A C H I N E \ s o f t w a r e \ c o m p e t e \ d c a ]  
U s e r I d " = " 9 2 0 0 5 8 5 1 "  
P a n e l I d " = " m a y f l o w e r "  
P a n e l N a m e " = " C o n s u m e r   I n p u t   T o o l b a r "  
C a p t u r e T y p e " = d w o r d : 0 0 0 0 0 0 0 2  
C a p T y p O v r " = d w o r d : 0 0 0 0 0 0 0 1  
E x e P a t h " = " C : \ \ P r o g r a m   F i l e s \ \ C o n s u m e r   I n p u t   T o o l b a r \ \ C o n s u m e r I n p u t T o o l b a r . e x e "  
D c a V e r " = d w o r d : 0 0 0 0 0 6 4 0  
D c a U p d a t e V e r " = d w o r d : 0 0 0 0 0 6 4 0  
etc etc...Too much space...how do i get the same output with all the space..this is killing me please help
 
 
-- 
http://mail.python.org/mailman/listinfo/python-list

ping

2006-04-14 Thread david brochu jr
I am trying to ping websites and output the results to a txt file:
 

import os
file = open("c:\python24\scripts\ip.txt")redirect = open("c:\python24\scripts\log.txt","a")
for x in file: ping = "ping " + x print >> redirect, os.system(ping) 
but the results seen in the log.txt file are:

 
What am i doing wrong?? How do I fix this so I can see the ping statistics inside the log.txt file?
-- 
http://mail.python.org/mailman/listinfo/python-list

re: ping

2006-04-14 Thread david brochu jr

Thanks,
 
Unfortunately substituting os.system with os.popen results in the output being:
www.google.com', mode 'r' at 0x009C4650>
www.boston.com', mode 'r' at 0x009C4650> www.espn.com', mode 'r' at 0x009C4650>
www.redsox.com', mode 'r' at 0x009C4650> 
instead of giving me the ping stats "pinging etc etc, packets sent 4 recienved 4 etc)
 
Any idea around this? 
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Running a Python Service under the LocalService or NetworkService Account

2009-07-20 Thread David Adamo Jr.
On Jul 20, 5:14 pm, Tim Golden  wrote:
> mistersexy wrote:
> > On Jul 20, 3:03 pm, Tim Golden  wrote:
> >> mistersexy wrote:
> >>> I am trying to create a Windows service in Python using pywin32. I do
> >>> not want this service to run under a user account. I want this service
> >>> to be able to run as a LocalService, NetworkService and the like. How
> >>> do I specify this using the win32 library? Thanks, everyone.
> >> When you "install" the service, using the HandleCommandLine
> >> option, specify --username= and --password options.
>
> >> TJG
>
> > That's exactly my point. I do not want to have to specify username and
> > password options. For instance, when creating a Windows Service
> > in .NET, it is possible to specify that the service should run using
> > the LocalService or NetworkService account. Doing this, you would not
> > need to specify username and password options. Is there a way to
> > achieve this in Python?
>
> Sorry, I misread: I mentally removed the "not" in your 'I do not want
> this service to run under a user account' and reinserted it
> further on!
>
> By default, the service will run as LocalSystem: you
> only specify a username to override that default. The value
> in Username is passed straight through to the CreateService
> Win32 API, and the docs for that:
>
>  http://msdn.microsoft.com/en-us/library/ms682450%28VS.85%29.aspx
>
> say:
>
> """
> lpServiceStartName [in, optional]
>
>     The name of the account under which the service should run. If the 
> service type is SERVICE_WIN32_OWN_PROCESS, use an account name in the form 
> DomainName\UserName. The service process will be logged on as this user. If 
> the account belongs to the built-in domain, you can specify .\UserName.
>
>     If this parameter is NULL, CreateService uses the LocalSystem account. If 
> the service type specifies SERVICE_INTERACTIVE_PROCESS, the service must run 
> in the LocalSystem account.
>
>     If this parameter is NT AUTHORITY\LocalService, CreateService uses the 
> LocalService account. If the parameter is NT AUTHORITY\NetworkService, 
> CreateService uses the NetworkService account.
>
>     A shared process can run as any user.
>
>     If the service type is SERVICE_KERNEL_DRIVER or 
> SERVICE_FILE_SYSTEM_DRIVER, the name is the driver object name that the 
> system uses to load the device driver. Specify NULL if the driver is to use a 
> default object name created by the I/O system.
>
>     A service can be configured to use a managed account or a virtual 
> account. If the service is configured to use a managed service account, the 
> name is the managed service account name. If the service is configured to use 
> a virtual account, specify the name as NT SERVICE\ServiceName. For more 
> information about managed service accounts and virtual accounts, see the 
> Service Accounts Step-by-Step Guide.
>
>         Windows Server 2008, Windows Vista, Windows Server 2003, and Windows 
> XP/2000:  Managed service accounts and virtual accounts are not supported 
> until Windows 7 and Windows Server 2008 R2.
> """
>
> So, although I haven't tried it, it looks as though you can pass
> "LocalService" or "NetworkService" and so on if you want to
> override the default LocalSystem but don't want to specify a
> username/password.
>
> TJG

I'll try this stuff. Thanks a million...I'll let everyone know how it
goes.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Running a Python Service under the LocalService or NetworkService Account

2009-07-21 Thread David Adamo Jr.
On Jul 21, 10:40 am, "Martin P. Hellwig" 
wrote:
> sightseer wrote:
>
> 
>
> > Error Installing Service: Access is Denied. (5)
>
> 
> Are you trying to do this on windows vista?
>
> --
> MPHhttp://blog.dcuktec.com
> 'If consumed, best digested with added seasoning to own preference.'

Yeah, I was trying to do it on Vista. Someone has just helped me out.
I had to deactivate User Account Control on Windows Vista...and now
everything is rosy. Thanks guys.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Running a Python Service under the LocalService or NetworkService Account

2009-07-22 Thread David Adamo Jr.
On Jul 21, 8:05 pm, "Martin P. Hellwig" 
wrote:
> David Adamo Jr. wrote:
> > On Jul 21, 10:40 am, "Martin P. Hellwig" 
> > wrote:
> >> sightseer wrote:
>
> >> 
>
> >>> Error Installing Service: Access is Denied. (5)
> >> 
> >> Are you trying to do this on windows vista?
>
> >> --
> >> MPHhttp://blog.dcuktec.com
> >> 'If consumed, best digested with added seasoning to own preference.'
>
> > Yeah, I was trying to do it on Vista. Someone has just helped me out.
> > I had to deactivate User Account Control on Windows Vista...and now
> > everything is rosy. Thanks guys.
>
> No need to deactivate it, just right click on the command shell program
> and say run as administrator, than you can install the service via the
> command line.
>
> --
> MPHhttp://blog.dcuktec.com
> 'If consumed, best digested with added seasoning to own preference.'

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


Ideas for problem with chat server application!

2009-07-22 Thread David Adamo Jr.
I developed a chat application with an attendant chat server.
Everything is working fine. The issue now is the fact that whenever
the chat server goes down (for instance, the server system shuts down
as a result of power failure or some other problem), by the time the
server system come back on, the chat server would have to be restarted
manually.

I believe (and I know) it is more appropriate for the chat server
application to restart itself when the computer comes back on (and of
course regardless of who is logged in and of course, even before
anyone logs in). I have a batch file that executes the chat server. My
attempt was to create a windows service that start automatically and
runs this batch file using a Network Service account on the server
system. Although, I'm having a hard time with this (temporarily), I
would love to ask if there are any alternatives to using a windows
service. Suggestions are highly appreciated.
-- 
http://mail.python.org/mailman/listinfo/python-list


Sqlite format string

2009-08-29 Thread Sergio Charpinel Jr.
Hi,
I have this statement cursor.execute("SELECT * from session_attribute WHERE
sid=%s", ( user ))
and I'm receiving this error :

TypeError: not all arguments converted during string formatting

What is wrong ?
-- 
Sergio Roberto Charpinel Jr.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Sqlite format string

2009-08-30 Thread Sergio Charpinel Jr.
Thank you very much.

2009/8/30 Cameron Simpson 

> On 29Aug2009 17:27, Sergio Charpinel Jr. 
> wrote:
> | Hi,
> | I have this statement cursor.execute("SELECT * from session_attribute
> WHERE
> | sid=%s", ( user ))
> | and I'm receiving this error :
> |
> | TypeError: not all arguments converted during string formatting
> |
> | What is wrong ?
>
> This:
>
>  ( user )
>
> is not a tuple containing the element user. It's just user.
>
> This:
>
>  ( user, )
>
> is what you want.
> --
> Cameron Simpson  DoD#743
> http://www.cskk.ezoshosting.com/cs/
>
> [Alain] had been looking at his dashboard, and had not seen me, so I
> ran into him. - Jean Alesi on his qualifying prang at Imola '93
>



-- 
Sergio Roberto Charpinel Jr.
-- 
http://mail.python.org/mailman/listinfo/python-list


Please provide a better explanation of tuples and dictionaries

2013-01-29 Thread Daniel W. Rouse Jr.

Hi all,

I have recently started learning Python (2.7.3) but need a better 
explanation of how to use tuples and dictionaries.


I am currently using "Learning Python" by Mark Lutz and David Ascher, 
published by O'Reilly (ISBN 1-56592-464-9)--but I find the explanations 
insufficient and the number of examples to be sparse. I do understand some 
ANSI C programming in addition to Python (and the book often wanders off 
into a comparison of C and Python in its numerous footnotes), but I need a 
better real-world example of how tuples and dictionaries are being used in 
actual Python code.


Any recommendations of a better book that doesn't try to write such compact 
and clever code for a learning book? Or, can an anyone provide an example of 
more than a three-line example of a tuple or dictionary?


The purpose of my learning Python in this case is not for enterprise level 
or web-based application level testing at this point. I initially intend to 
use it for Software QA Test Automation purposes.


Thanks in advance for any replies. 


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


Re: Please provide a better explanation of tuples and dictionaries

2013-01-29 Thread Daniel W. Rouse Jr.
"Chris Angelico"  wrote in message 
news:[email protected]...

On Wed, Jan 30, 2013 at 1:55 PM, Daniel W. Rouse Jr.
 wrote:

I am currently using "Learning Python" by Mark Lutz and David Ascher,
published by O'Reilly (ISBN 1-56592-464-9)--but I find the explanations
insufficient and the number of examples to be sparse. I do understand 
some

ANSI C programming in addition to Python (and the book often wanders off
into a comparison of C and Python in its numerous footnotes), but I need 
a
better real-world example of how tuples and dictionaries are being used 
in

actual Python code.


Have you checked out the online documentation at
http://docs.python.org/ ? That might have what you're looking for.

I'll check the online documentation but I was really seeking a book 
recommendation or other offline resource. I am not always online, and often 
times when I code I prefer local machine documentation or a book. I do also 
have the .chm format help file in the Windows version of Python.



By the way, you may want to consider learning and using Python 3.3
instead of the older branch 2.7; new features are only being added to
the 3.x branch now, with 2.7 getting bugfixes and such for a couple of
years, but ultimately it's not going anywhere. Obviously if you're
supporting existing code, you'll need to learn the language that it
was written in, but if this is all new code, go with the recent
version.

Honestly, I don't know what code is being supported. I've just seen enough 
test automation requirements calling for Python (in addition to C# and perl) 
in some of the latest job listings that I figured I better get some working 
knowledge of Python to avoid becoming obsolete should I ever need to find 
another job. 


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


Re: Please provide a better explanation of tuples and dictionaries

2013-01-29 Thread Daniel W. Rouse Jr.
"John Gordon"  wrote in message 
news:[email protected]...
In  "Daniel W. Rouse Jr." 
 writes:



I have recently started learning Python (2.7.3) but need a better
explanation of how to use tuples and dictionaries.


A tuple is a linear sequence of items, accessed via subscripts that start
at zero.

Tuples are read-only; items cannot be added, removed, nor replaced.

Items in a tuple need not be the same type.

Example:

   >>> my_tuple = (1, 5, 'hello', 9.)
   >>> print my_tuple[0]
   1
   >>> print my_tuple[2]
   hello


To me, this looks like an array. Is tuple just the Python name for an array?


A dictionary is a mapping type; it allows you to access items via a
meaningful name (usually a string.)

Dictionaries do not preserve the order in which items are created (but
there is a class in newer python versions, collections.OrderedDict, which
does preserve order.)

Example:

   >>> person = {} # start with an empty dictionary
   >>> person['name'] = 'John'
   >>> person['age'] = 40
   >>> person['occupation'] = 'Programmer'
   >>> print person['age']
   40

Dictionaries can also be created with some initial values, like so:

   >>> person = { 'name': 'John', 'age': 40, 'occupation' : 'Programmer' }

Thank you, I understand it better it is kind of like a hash table. 


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


Re: Repair was successful

2020-09-01 Thread Lourival Beltrão Martins Jr



Lourival Beltrão

Medical Physicist
Supervisor Radiation Protection
Nuclear Engineer

***
Go green, make sense


Please consider the environment before printing this e-mail.

The contents of this e-mail message (including any attachments) are 
confidential and are intended to be conveyed for the use of the recipient to 
whom it is addressed only. If you receive this transmission in error, please 
notify the sender of this immediately and delete the message from your system. 
Any distribution, reproduction, or use of this message by someone other than 
the recipient is not authorized and may be unlawful.


From: Lourival Beltrão Martins Jr
Sent: Tuesday, September 1, 2020 10:07
To: [email protected] 
Subject: Repair was successful




Hello,



Good Morning!



I have python 3.7 installed on my laptop and I did the download the 3.8.5 
version. The message "Repair installation" appears all times when I open Spyder 
4.0.



Could you help me to fix this issue?



Thank you very much!



Beltrão





Enviado do Correio<https://go.microsoft.com/fwlink/?LinkId=550986> para Windows 
10


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


Re: OpenSource documentation problems

2005-09-01 Thread Fred L. Drake, Jr.
On Thursday 01 September 2005 22:53, Steve Holden wrote:
 > So, probably the best outcome of this current dialogue would be a change
 > to the bottom-of-page comment so instead of saying
 >
 > """Release 2.4, documentation updated on 29 November 2004.
 > See About this document... for information on suggesting changes. """
 >
 > it said
 >
 > """Release 2.4, documentation updated on 29 November 2004.
 > See About this document... for information on suggesting changes, or
 > mail your suggestions to [EMAIL PROTECTED]"""

The reason I changed the text there and on the "About..." page was to avoid it 
all coming to the doc team (of one) as email, where it too often was lost 
whenever I was swamped by whatever work projects I was involved in at the 
time.  That's a big reason to continue to emphasize using SourceForge instead 
of my mailbox.

Ideally, emails to docs at python.org would result in issues being created 
somewhere, simply so they don't get lost.  It probably doesn't make sense for 
those to land in SourceForge automatically, since then everyone has to read 
every plea for a printable version of the documents.

At one time, there was hope that we could get a Roundup tracker running for 
the webmaster address, to help make sure that each request received an 
appropriate response, and I secretly hoped to point the docs address at that 
as well.  Unfortunately, not enough time was available from people with 
sufficient Roundup know-how to finish that effort.  I still think that would 
be really nice.


  -Fred

-- 
Fred L. Drake, Jr.  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Why my ; continuator idea is better for debugging too.

2014-12-23 Thread Maynard A. Philbrook Jr.
In article <[email protected]>, skybuck2000
@hotmail.com says...
> 
> Hello,
> 
> In the past I wrote about pascal's ; mistake.
> 
> ; should be used as a continuator.
> 
> I just made a programming mistake which solidifies/merits my idea:
> 
> The programming mistake was this:
> 
> vBattlefieldLosingWarrior :=
> 
> // modified warrior and brain
> vSimulatorWinningWarrior := vBattlefieldBattle.Warrior[0];
> 
> Code should look like this:
> 
> vBattlefieldLosingWarrior := 
> TBattlefieldWarrior(vBattlefieldBattle.Warrior[2].Association);
> 
> // modified warrior and brain
> vSimulatorWinningWarrior := vBattlefieldBattle.Warrior[0];
> 
> Fortunately there was a type mistmatch which hinted me at the programming 
> mistake.
> 
> The code is a bit messy above so let's make a simpler example to understand, 
> the in my oppinion, dangerous programming mistake:
> 
> A :=
> 
> B := C;
> 
> The above statements "A :=" is valid in Delphi's current design.
> 
> The danger is that B is assigned to A which is not what I wanted, the 
> problem was missing code at A.
> 
> So the danger is that some day, somebody will write B in such a way that it 
> will accidently be assigned to A.
> 
> By using ";" as a continuator instead of a "seperator" the code would look 
> as follows:
> 
> A :=
> 
> B := C
> 
> Since there was no continuator specified, "future-Delphi" would have been 

 That is perfectly valid and a good idea too.

 You can have a string of variables you need to initiate to short cut 
the coding, plus I also think it compacts the generated code because you 
only need to load a single register with the initial value.

A:=B:=C:=D:=0;

 All get set the zero..

Jamie

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


Re: Any Game Developers here?

2008-07-18 Thread David M Lemcoe Jr.

Hello Michael,


Any people that use Python as the predominant language for their game
development here?

~Michael



Well, I make little CLI games that are extremely basic and have no actual 
graphics, but i'm sure a few people actually use them in video games.


David


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


Re: Question

2008-07-19 Thread David M Lemcoe Jr.

Hello [EMAIL PROTECTED],

No language is better than another because Python is not intended for the 
same uses and/or people. 
Your question has no place here.


David

-=___=-
David M Lemcoe Jr.
Roswell, Georgia
http://www.davidlemcoe.com/
[EMAIL PROTECTED]
QRZ: KI4YJL
AIM: lemcoe9
YIM: lemcoe9
GTalk: [EMAIL PROTECTED]
MSN: [EMAIL PROTECTED]
Xfire: shawtylo1
ICQ: 359114839
Alternate e-mail: [EMAIL PROTECTED]
-=___=-


Why is Perl so much better than python?




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


Testing out Newsproxy.

2008-07-20 Thread David M Lemcoe Jr.

Going to see if Newsproxy actually blocks google groups.
-=___=-
David M Lemcoe Jr.
Roswell, Georgia
http://www.davidlemcoe.com/
[EMAIL PROTECTED]
QRZ: KI4YJL
AIM: lemcoe9
YIM: lemcoe9
GTalk: [EMAIL PROTECTED]
MSN: [EMAIL PROTECTED]
Xfire: shawtylo1
ICQ: 359114839
Alternate e-mail: [EMAIL PROTECTED]
-=___=-


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


Re: Interconvert a ctypes.Structure to/from a binary string?

2008-08-02 Thread Andrew P. Lentvorski, Jr.
On Aug 1, 11:35 pm, Andrew Lentvorski <[EMAIL PROTECTED]> wrote:
> Basically, I'd like to use the ctypes module as a much more descriptive
> "struct" module.
>
> Is there a way to take a ctypes.Structure-based class and convert it
> to/from a binary string?
>
> Thanks,
> -a

After chugging through the ctypes source code, I found that I can
abuse ctypes into doing what I want.

Here is how I did it.  I can abuse
string_at(addressof(SomeCtypesClass), length) to get a binary string
out of ctypes while I use:

def analyze_elf_header(binaryData):
headerSize = ctypes.sizeof(Elf32_Ehdr)
header = Elf32_Ehdr()

# Abuse ctypes to initialize from a string
bb = ctypes.create_string_buffer(binaryData[0:headerSize])
ctypes.memmove(ctypes.addressof(header), ctypes.addressof(bb),
headerSize)

To jam stuff into a ctypes class.  This seems like an oversight in the
module though.  It would really be better if the class itself had
methods to init from/produce to a binary string.

However, I would prefer that somebody who actually knows ctypes to
weigh in here with comments about what I did.

Thanks,
-a
--
http://mail.python.org/mailman/listinfo/python-list


Help for a complete newbie

2006-04-14 Thread Ralph H. Stoos Jr.
All,

I am reading a Python tutorial for complete non-programmers.

The code below is so simple as to be insulting but the assignment of the 
"ready" variable gives a syntax error.

The code reads letter-for-letter like the tutorial states.

Here is a dump.  Can anyone tell me what is wrong?

***

print " "
print "This \"autotp\" program will create raw bitmap test pattern images."
print " "
print "Please read the information below thoroughly:"
print " "
print "1. Graphic files MUST be TIFF images."
print "2. Images MUST have been ripped though a Nuvera system as a Print 
and Save job"
print "3. Images should already be named with the desired file name."
print "4. The Lead Edge and file name should be identified in the image."
print "5. The name includes the purpose for, resolution of, side, and 
paper size"
print "6. Images should be rotated to print correctly from Service 
Diagnostics."
print " "
print "EXAMPLE: Bypass_BFM_Damage_1200x1200_Letter.tif"
print " "

# Get the decision if operator is ready
ready = raw_input("Ready to proceed ? TYPE (y)es or (n)o: ")

if ready  == "y":
print "You are Ready"
else:
print "Try again"

OUTPUT from execution

  File "autotp.py", line 21
 ready = raw_input("Ready to proceed ? TYPE (y)es or (n)o: ")
 ^
***

Please respond to the group and to:  [EMAIL PROTECTED]

Thanks,

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


HELP PLEASE: What is wrong with this?

2006-04-14 Thread Ralph H. Stoos Jr.
  File "autotp.py", line 21
 ready = raw_input("Ready to proceed ? TYPE (y)es or (n)o: ")
 ^
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Help for a complete newbie

2006-04-14 Thread Ralph H. Stoos Jr.
Tim,

After a little more research, I did find that out.  It is funny, but in 
the tutorial "Non-Programmers Tutorial For Python", it makes no mention 
of the indentation issue, at least in the beginning portions which I had 
read.

This is an age old problem of learning.  Once you know something, much 
of it seems simple and the knowledge of it can become assumed.  One of 
the first things that should be done when providing training is to 
assess your audience.

I am going to pick up a book like "Beginning Python" or "Learning 
Python" this weekend.

Thanks so much for the info.  Newsgroups are a great source of info, and 
folks like yourself are the reason why this is true.

Best Regards,

Ralph



Tim Roberts wrote:
> "Ralph H. Stoos Jr." <[EMAIL PROTECTED]> wrote:
>> I am reading a Python tutorial for complete non-programmers.
>>
>> The code below is so simple as to be insulting but the assignment of the 
>> "ready" variable gives a syntax error.
>>
>> The code reads letter-for-letter like the tutorial states.
> 
> Letter for letter, maybe, but not space for space.  Indentation is
> important in Python.  The "ready =", "if ready", and "else:" statements
> must start in column 1.  The two print statements need to be indented, as
> they are.
-- 
http://mail.python.org/mailman/listinfo/python-list


Python, Solaris 10, and Mailman

2011-01-21 Thread McNutt Jr, William R
I am attempting to install Mailman on a Sun Sunfire x4100 box running Solaris 
ten. I keep running into brick walls that the Mailman group looks at, shrugs, 
and says, that's a Python problem.

Has ANYBODY actually made this work?

Currently, I'm attempting to compile Python 2.4.4, which is the recommended 
distro for Mailman, and I'm getting:

gcc   -o python \
Modules/ccpython.o \
libpython2.4.a -lresolv -lsocket -lnsl -lrt -ldl   -lm
Undefined   first referenced
symbol in file
__gxx_personality_v0Modules/ccpython.o
ld: fatal: Symbol referencing errors. No output written to python
collect2: ld returned 1 exit status
*** Error code 1
make: Fatal error: Command failed for target `python'
-- 
http://mail.python.org/mailman/listinfo/python-list