import

2007-07-05 Thread jolly
Hey guys,

I'm rather new to python and i'm have trouble(as usual)

I want to know if it is possible to change where 'import' looks
this will save me clogging up my python directory

Thanks

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


NOOOOB

2007-05-22 Thread jolly
Hey guys,

I want to begin python. Does anyone know where a good starting point
is?

Thanks,
Jem

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


NameError: name 'main' is not defined

2007-12-18 Thread jolly
hey guys,

When i try to run my code I get an error. NameError name 'main is not
defined'

[code]
if __name__ == "__main__":
main()

filename = "addbook.dat"

def main():
theMenu = '''
1) Add Entry
2) Remove Entry
3) Find Entry
4) Quit and Save
'''
theBook = {}
readBook(theBook)
choice = getChoice(theMenu)
while choice != 4:
if choice == 1:
addEntry(book)
elif choice == 2:
removeEntry(book)
elif choice == 3:
findEntry(book)
else:
print "Invalid choice, try again."
choice = getChoice(theMenu)
saveBook(theBook)


def readbook(book):
import os
if os.path.exists(filename):
store = open(filename,'r')
for line in store:
name = line.rstrip()
entry = store.net().rstrip
book[name] = entry
store.close()

def saveBook(book):
store = open(filename,'w')
for name,entry in book.items():
store.write(name + '\n')
store.write(entry + '\n')
store.close()

def getChoice(menu):
print menu
choice = int( raw_input("Select a choice(1-4): ") )
return choice

def addEntry(book):
name=raw_input("Enter a name: ")
entry = raw_input("Enter a street, town and phone number: ")
book[name] = entry

def removeEntry(book):
name=raw_input("Enter a name: ")
del(book[name])

def findEntry(book):
name = raw_input("Enter a name: ")
if name in book:
print name, book[name]
else: print "Sorry, no entry for: ",name


[/code]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: NameError: name 'main' is not defined

2007-12-18 Thread jolly
thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


Help %A in time.strftime(%A)

2007-12-19 Thread jolly
Hey guys,

I'm following a tutorial on Python and I came across this in one of
the examples.
(Toggle Plain Text)

import time

today = time.localtime(time.time())
theDate = time.strftime("%A %B %d", today)

print today
print theDate

import time today = time.localtime(time.time()) theDate =
time.strftime("%A %B %d", today) print today print theDate
Result:
(Toggle Plain Text)

(2007, 12, 20, 9, 48, 15, 3, 354, 1)
Thursday December 20

(2007, 12, 20, 9, 48, 15, 3, 354, 1) Thursday December 20

can someone explain to me the %A and the %B?

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


Help %A in time.strftime(%A)

2007-12-19 Thread jolly
Hey guys,

I'm following a tutorial on Python and I came across this in one of
the examples.

import time

today = time.localtime(time.time())
theDate = time.strftime("%A %B %d", today)

print today
print theDate


Result:


(2007, 12, 20, 9, 48, 15, 3, 354, 1)
Thursday December 20


can someone explain to me the %A and the %B?

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


Question on multiple Python users in one application

2016-10-06 Thread Jolly Good Spam

Hello. Please pardon a newbie question.

I have a Windows multi-user program that can be used by an arbitrary number 
of users at once. They can work independently, or they can share data at the 
file or even variable level if they want. I want to give them the ability to 
write Python programs within this environment. So I intend to embed CPython 
access in the program.


The basic embedding of CPython seems straight forward. But since I have 
multiple users, each needs their own Python sandbox, so if they all compile 
programs with variable 'spam', it doesn't collide. Of course they can all 
have different programs running at the same time too.


I think I need to do some behind-the-scenes thread management and possibly 
namespace management to allow this to work correctly. But this is where I'm 
confused, and not sure where to start. I know how to tell my users apart. 
The program is multi-threaded, but there is not a direct correspondence 
between a user and a thread; a single user can switch threads, but I know 
when this happens.


Can someone please suggest what I should be looking at and doing to be able 
to effectively run multiple independent Pythons in a single program?


Thank you for your help!

   Loren

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