Re: Tuple index

2005-02-21 Thread Steve M
Steven Bethard wrote: > Steve M wrote: >> I'm actually doing this as part of an exercise from a book. What the >> program is supposed to do is be a word guessing game. The program >> automaticly randomly selects a word from a tuple. You then have the >> oportun

Re: Copy functio in imaplib

2005-02-22 Thread Max M
a string. In one of the forms: '1,2,3,4' or '1:4' The numbers can be either message sequence numbers or uids. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: UTF-8 / German, Scandinavian letters - is it really this difficult?? Linux & Windows XP

2005-02-22 Thread Max M
g an encoding: ust = unicode(st) -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: Explicit or general importing of namespaces?

2005-02-28 Thread Max M
able. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: [Python-Dev] Re: python-dev Summary for 2005-01-16 through 2005-01-31

2005-03-02 Thread Max M
hared effort" in the single sub-project, it might very well be on a higher level. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: Best way to make a list unique?

2005-03-08 Thread Max M
can be a little simpler: listA = list(Set(listA)) You don't even need to convert it to a list. You can just iterate over the set. >>> la = [1,2,3,4,3,2,3,4,5] >>> from sets import Set >>> sa = Set(la) >>> for itm in sa: ... print itm 1 2 3

Re: split a string with quoted parts into list

2005-03-10 Thread Max M
ted sub entries into a list of strings? In Twisteds protocols/imap4.py module there is a function called parseNestedParens() that can be ripped out of the module. I have used it for another project and put it into this attachment. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad S

Re: csv module and unicode, when or workaround?

2005-03-12 Thread Max M
x27;t support unicode, but you should not have problem importing/exporting encoded strings. I have imported utf-8 encoded string with no trouble. But I might just have been lucky that they are inside the latin-1 range? -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Scien

Re: Why tuple with one item is no tuple

2005-03-15 Thread Max M
Gregor Horvath wrote: thanks are given to all "problem" solved... Personally I add a , after every list/tuple item. Also the last. It also makes copy/pasting code easier. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/

IMAP UTF-7, any codec for that anywhere?

2004-12-01 Thread Max M
Convention -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: IMAP UTF-7, any codec for that anywhere?

2004-12-01 Thread Max M
Brian Quinlan wrote: > Max M wrote: > >> Is there any codec available for handling The special UTF-7 codec for >> IMAP? > Is there something special do you need or is recipe OK? > > >>> u"\u00ff".encode('utf-7') > '+AP8-' A

Re: Need help on program!!!

2004-12-03 Thread Max M
dice1, dice2 = rolldice() roll += 1 if dice1 + dice2 == 7: print 'Too bad, you loose in roll %s' % roll result = None elif (dice1, dice2) == (first1, first2): print 'Congratulations, you win in roll %s' % roll result = None Hopefully h

Re: Need help on program!!!

2004-12-03 Thread Max M
Dan Perl wrote: "Max M" <[EMAIL PROTECTED]> wrote in message Most of us here have been students (or still are) and may sympathize with the OP, but personally I have been also a TA so I have seen the other side and that's where my sympathy lies now. My reply was a joke... M

Re: Psycopg 1.1.17 compiled binaries for windows, postgre 8.0.0-beta4 and python 2.3

2004-12-09 Thread Max M
://initd.org/projects/psycopg1 Postgres runs fine on Windows now in a native version. And pgAdmin is a pretty nice tool. A precompiled psycopg is the missing link. Thanks. I will try it out. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/ma

Re: Persistent objects

2004-12-12 Thread Max M
app and restart it later, there'd be a way to bring d back into the process and have that Frob instance be there. Have you considdered using the standalone ZODB from Zope? -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: do you master list comprehensions?

2004-12-13 Thread Max M
u might be more comfortable with: data = [['foo','bar','baz'],['my','your'],['holy','grail']] result = [] for l in data: result += l -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: do you master list comprehensions?

2004-12-13 Thread Max M
Fredrik Lundh wrote: Max M wrote: I tried funnies like [[w for w in L] for L in data], That is absolutely correct. It's not a funnie at all. well, syntactically correct or not, it doesn't do what he want... Doh! *I* might not be used to list comprehensions then... You are right. Th

Re: Help need with converting Hex string to IEEE format float

2004-12-14 Thread Max M
nd stuff. You should get tons of answers. ## st = '80 00 00 00' import binascii import struct s = ''.join([binascii.a2b_hex(s) for s in st.split()]) v = struct.unpack("f", s)[0] print v ## regards Max M -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: python re - a not needed

2004-12-16 Thread Max M
ftware/BeautifulSoup/ I will most likely do what you want in 2 or 3 lines of code. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: Why are tuples immutable?

2004-12-16 Thread Max M
t the time taken to convert a list into a tuple. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: character encoding conversion

2004-12-13 Thread Max M
return st_encoded, encoding except UnicodeError: pass st = 'Test characters æøå ÆØÅ' encodings = ['utf-8', 'latin-1', 'ascii', ] print get_encoded(st, encodings) (u'Test characters \xe6\xf8\xe5 \xc6\xd8\xc5', '

Re: Python To Send Emails Via Outlook Express

2004-12-19 Thread Max M
using those email adresse, or you don't log on with the correct credentials. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: Is this a good use for lambda

2004-12-20 Thread Max M
The entity Fredrik Lundh wrote: Isn't it about time you became xml avare, and changed that to: ? -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: Is this a good use for lambda

2004-12-20 Thread Max M
Steve Holden wrote: Max M wrote: Isn't it about time you became xml avare, and changed that to: Yeah, but give the guy a break, we've all made feeble attempts at humor from time to time. Hey, what's wrong with a little nørd humor... I just found it amusing that somenone like Fred

Re: Python To Send Emails Via Outlook Express

2004-12-20 Thread Max M
to find those than it is to use them as the sender. Most email clients can fetch the settings from other mail clients, so it's been done before. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: MIDI library recommendations, please?

2004-12-20 Thread Max M
project which does that on different platforms. But I am not aware how well they work. The best place to ask is probably on the Python Midi list at: http://sourceforge.net/mail/?group_id=113783 -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/ma

Re: Python To Send Emails Via Outlook Express

2004-12-24 Thread Max M
= MapiMessage(0, subject, body, None, None, None, 0, cast(NULL, lpMapiRecipDesc), RecipCnt, recip, nFileCount, lpFiles) rc = MAPISendMail(0, 0, byref(msg), 0, 0) if rc != SUCCESS_SUCCESS: raise WindowsError, "MAPI error %i" % rc --- Looks good. Lenard Lindstrom Nice quoting -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: Python To Send Emails Via Outlook Express

2004-12-25 Thread Max M
Steve Holden wrote: Max M wrote: Lenard Lindstrom wrote: So what is this, some kind of competition? If you really though Lenard's quoting was a sin (since I took your remarks to be sardonic), how much more so was your gratuitous repetition thereof? I thought that showing by example might h

Re: How to create an object instance from a string??

2005-03-20 Thread Max M
#x27;)() -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: Version Number Comparison Function

2005-03-25 Thread Steve M
I recently saw this: http://www.egenix.com/files/python/mxTools.html mx.Tools.verscmp(a,b) Compares two version strings and returns a cmp() function compatible value (<,==,> 0). The function is useful for sorting lists containing version strings. The logic used is as follows: the string

Actor pattern in GUI

2005-03-29 Thread M Ali
Hi, I am trying to grok using actor patterns in a gui as explained here by Andrew Eland: http://www.andreweland.org/code/gui-actor.html The short article explains it using java with which i am not used to at all. But he does provide a python example using pygtk: http://www.andreweland.org/code/g

Re: IMAP4.search by message-id ?

2005-03-29 Thread Max M
ror Why do you need the 'HEADER' Wouldn't this be enough? resp, items = server.search(None, 'Message-id', msgID) I am note shure if the msgId should be quoted. I assume not, as it will allways be an integer. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: oddness in string.find(sub,somestring)

2005-03-30 Thread Max M
are you going to fix it? -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: oddness in string.find(sub,somestring)

2005-03-30 Thread Max M
_string, substring) # note the order searched_string="" print string.find(searched_string, substring) You will not make that error if you use the string method instead. searched_string.find(substring) And you don't have to import anything either.. -- hilsen/regards Max M, Denmar

Re: Actor pattern in GUI

2005-03-30 Thread M Ali
Hmm... no takers? Too bad, the pattern and it's implementation in python is pretty interesting... [EMAIL PROTECTED] (M Ali) wrote in message news:<[EMAIL PROTECTED]>... > Hi, > > I am trying to grok using actor patterns in a gui as explained here by > Andrew Eland: >

Re: Generating RTF with Python

2005-03-31 Thread Max M
at this a while ago, which might be a starter. http://pyrtf.sourceforge.net/ -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem with national characters

2005-03-31 Thread Max M
your strings as unicode, do the transfom, and encode it back as latin1. print repr('før'.decode('latin-1').upper().encode('latin-1')) # 'F\xd8R' print repr('FØR'.decode('latin-1').encode('latin-1')) 'F\xd8R' -- hilsen

Re: Problems extracting attachment from email

2005-04-08 Thread Max M
I see that the last 255 bytes are missing. How is this possible, I receive every last byte from stdin? I don't think its a Python problem. Those methods are used in a lot of places. Your file is most likely not what it is supposed to be. -- hilsen/regards Max M, Denmark http://www.mxm.dk/

Re: doubt regarding Conversion of date into timestamp

2005-04-08 Thread Max M
praba kar wrote: Dear All, I am new to Python I want to know how to change a time into timestamp Is there any specific reason for not using datetime instead of time ? -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science -- http://mail.python.org/mailman/listinfo/python-list

Re: THE GREATEST NEWS EVER ! °º¤ø,¸¸,ø¤º°`°º¤ø°º¤ø,¸¸,ø¤º°`°º¤ø°º¤ø,¸¸,ø¤º°`°º¤ø°º¤ø,¸¸,ø¤º°`°º¤ø°º¤ø,¸¸,ø¤º°`°º¤ø°º¤ø,¸¸,ø¤º°`°º¤ø°º¤ø,¸¸,ø¤º°`°º¤ø°º¤ø,¸¸,ø¤º°`°º¤ø°º¤ø,¸¸,ø¤º°`°º¤ø°º¤ø,¸¸,ø¤º°`°º¤ø°º¤ø,¸¸,ø¤º°`°º¤ø

2005-04-08 Thread Scott M.
>From your site: "The reason some people don't know for sure if they are going to Heaven when they die is because they just don't know." Isn't that like saying the reason I'm not a rocket scientist is because I'm not a rocket scientist? <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTEC

Re: Can dictionary values access their keys?

2005-04-08 Thread Max M
Matthew Thorley wrote: I am creating an object database to store information about network devices, e.g. switches and routers. Possible usefull pages? http://www.python.org/doc/essays/graphs.html more at: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/119466 -- hilsen/regards Max M

Function to log exceptions and keep on truckin

2005-04-14 Thread Steve M
import sys, traceback def e2str(id): """Return a string with information about the current exception. id is arbitrary string included in output.""" exc = sys.exc_info() file, line, func, stmt = traceback.extract_tb(exc[2])[-1] return("%s: %s line %s (%s): %s" % (id, func, line, rep

Re: To decode the Subject =?iso-8859-2?Q?=... in email in python

2005-04-20 Thread Max M
ecode such a subject, returning a unicode string? The use would be like human_readable = cool_library.decode_equals(message['Subject']) parts = email.Header.decode_header(header) new_header = email.Header.make_header(parts) human_readable = unicode(new_header) -- hilse

Re: compile shebang into pyc file

2005-04-27 Thread Steve M
I just happened across the page linked to below, and remembered this thread, and, well... here you go: http://www.lyra.org/greg/python/ Executable .pyc files Ever wanted to drop a .pyc file right into your web server's cgi-bin directory? Frustrated because the OS doesn't know what to do with

Periodic execution with asyncio

2013-11-22 Thread Tobias M.
Hello guys, I am using the asyncio package (Codename 'Tulip'), which will be available in Python 3.4, for the first time. I want the event loop to run a function periodically (e.g. every 2 seconds). PEP 3156 suggests two ways to implement such a periodic call: 1. Using a callback that resched

Re: Periodic execution with asyncio

2013-11-23 Thread Tobias M.
Thanks a lot for your helpful posts, Terry! On 11/23/2013 01:00 AM, Terry Reedy wrote: * Make the task function a parameter 'func'. I actually like subclassing, but yes I know there are some downsides :) * Rename start to _set to better describe what is does and call it in the _run function

Re: Periodic execution with asyncio

2013-11-26 Thread Tobias M.
, Tobias M. wrote: >> Now putting this into a PeriodicTask class that provides a similar >interface >> like our callback version, I get: >> >> >> import asyncio >> >> class PeriodicTask2(object): >> >> def __init__(self, func, interval):

Using asyncio in event-driven network library

2013-12-23 Thread Tobias M.
Hello, I am currently writing an event-driven client library for a network protocol [1] and chose to use the new asyncio module. I have no experience with asynchronous IO and don't understand all the concepts in asyncio yet. So I'm not sure if asyncio is actually the right choice . My goal:

Re: Using asyncio in event-driven network library

2013-12-24 Thread Tobias M.
Thanks for your answers! I didn't have the time to test any of your suggestions so far but they already gave me something to think about. At least now I'm much more clearer on what I am actually looking for. On 23.12.2013 20:59, Terry Reedy wrote: What would be easiest for user-developers wou

Re: Variables in a loop, Newby question

2013-12-24 Thread Tobias M.
On 24.12.2013 17:07, vanommen.rob...@gmail.com wrote: Hello, for the first time I'm trying te create a little Python program. (on a raspberri Pi) I don't understand the handling of variables in a loop with Python. Lets say i want something like this. x = 1 while x <> 10 var x = x

Re: Converting py files to .exe and .dmg

2015-12-28 Thread Adam M
On Monday, December 28, 2015 at 10:35:41 AM UTC-5, Brian Simms wrote: > Hi there, > > I have done a lot of looking around online to find out how to convert Python > files to .exe and .dmg files, but I am confused. Could someone provide > pointers/advice as to how I can turn a Python file into a

x=something, y=somethinelse and z=crud all likely to fail - how do i wrap them up

2016-01-30 Thread Veek. M
I'm parsing html and i'm doing: x = root.find_class(... y = root.find_class(.. z = root.find_class(.. all 3 are likely to fail so typically i'd have to stick it in a try. This is a huge pain for obvious reasons. try: except something: x = 'default_1' (repeat 3 times) Is there some other

Re: x=something, y=somethinelse and z=crud all likely to fail - how do i wrap them up

2016-01-30 Thread Veek. M
Chris Angelico wrote: > On Sun, Jan 31, 2016 at 3:58 PM, Veek. M wrote: >> I'm parsing html and i'm doing: >> >> x = root.find_class(... >> y = root.find_class(.. >> z = root.find_class(.. >> >> all 3 are likely to fail so typically i&

Re: x=something, y=somethinelse and z=crud all likely to fail - how do i wrap them up

2016-01-30 Thread Veek. M
Veek. M wrote: > Chris Angelico wrote: > >> On Sun, Jan 31, 2016 at 3:58 PM, Veek. M wrote: >>> I'm parsing html and i'm doing: >>> >>> x = root.find_class(... >>> y = root.find_class(.. >>> z = root.find_class(.. >>

Re: x=something, y=somethinelse and z=crud all likely to fail - how do i wrap them up

2016-01-31 Thread Veek. M
Thanks guys: you've given me some good ideas - I really need to re-read the lxml docs for xpath. (basically trying to scrape ebay and score a mobo - ebaysdk doesn't work) Also need to google those principles :) thanks! (i knew one shouldn't overly rely on chained attribute lookups - didn't fig

coroutine, throw, yield, call-stack and exception handling

2016-02-08 Thread Veek. M
Exceptions can be raised inside a coroutine using the throw( Exceptions raised in this manner will originate at the currently executing yield state-ment in the coroutine.A coroutine can elect to catch exceptions and handle them as appropriate. It is not safe to use

Re: coroutine, throw, yield, call-stack and exception handling

2016-02-08 Thread Veek. M
Veek. M wrote: > > Exceptions can be raised inside a coroutine using the throw( > > Exceptions raised in this manner will originate at the currently > executing yield state-ment in the coroutine.A coroutine can elect to > catch exceptions

Re: coroutine, throw, yield, call-stack and exception handling

2016-02-09 Thread Veek. M
Ian Kelly wrote: > On Mon, Feb 8, 2016 at 2:17 AM, Veek. M wrote: >> >> Exceptions can be raised inside a coroutine using the throw( >> >> Exceptions raised in this manner will originate at the currently >> executing yield state-ment

How do i instantiate a class_name passed via cmd line

2016-02-13 Thread Veek. M
I'm writing a price parser. I need to do the equivalent of perl's $$var to instantiate a class where $car is the class_name. I'm passing 'Ebay' or 'Newegg' or 'Amazon' via cmd-line. I have a module named ebay.py and a class called Ebay (price parser). I do something like: \> main.py ebay mother

Re: How do i instantiate a class_name passed via cmd line

2016-02-13 Thread Veek. M
Rick Johnson wrote: > On Saturday, February 13, 2016 at 10:41:20 PM UTC-6, Veek. M wrote: >> how do i replace the 'Ebay' bit with a variable so that I >> can load any class via cmd line. > > Is this what you're trying to do? > > (Python2.x code)

Re: How do i instantiate a class_name passed via cmd line

2016-02-13 Thread Veek. M
Gregory Ewing wrote: > Veek. M wrote: >> I'm writing a price parser. I need to do the equivalent of perl's >> $$var to instantiate a class where $car is the class_name. >> >> I'm passing 'Ebay' or 'Newegg' or 'Amazon' via c

repr( open('/etc/motd', 'rt').read() )

2016-02-15 Thread Veek. M
When I do at the interpreter prompt, repr( open('/etc/motd', 'rt').read() ) i get # 1 #: "'\\nThe programs included with the Debian GNU/Linux system are free software;\\nthe exact distribution terms for each program are described in the\\nindividual files in /usr/share/doc/*/copyright.\\n\\nDe

threading - Doug Hellman stdlib book, Timer() subclassing etc

2016-02-16 Thread Veek. M
In Doug Hellman's book on the stdlib, he does: import threading import logging logging.basicConfig(level=logging.DEBUG, format=’(%(threadName)-10s) %(message)s’, ) class MyThreadWithArgs(threading.Thread): def __init__(self, group=None, target=None, name=None, args=(), kwargs=None

Lookahead while doing: for line in fh.readlines():

2016-02-27 Thread Veek. M
I want to do something like: #!/usr/bin/env python3 fh = open('/etc/motd') for line in fh.readlines(): print(fh.tell()) why doesn't this work as expected.. fh.readlines() should return a generator object and fh.tell() ought to start at 0 first. Instead i get the final count repeated for th

Re: Lookahead while doing: for line in fh.readlines():

2016-03-04 Thread Veek. M
Terry Reedy wrote: > On 2/27/2016 4:39 AM, Veek. M wrote: >> I want to do something like: >> >> #!/usr/bin/env python3 >> >> fh = open('/etc/motd') >> for line in fh.readlines(): >> print(fh.tell()) >> >> why doesn't th

Re: Lookahead while doing: for line in fh.readlines():

2016-03-04 Thread Veek. M
MRAB wrote: > On 2016-03-04 13:04, Veek. M wrote: >> Terry Reedy wrote: >> >>> On 2/27/2016 4:39 AM, Veek. M wrote: >>>> I want to do something like: >>>> >>>> #!/usr/bin/env python3 >>>> >>>> fh = open('/etc

__del__: when to use it? What happens when you SystemExit/NameError wrt del? Method vs function calls.

2016-03-06 Thread Veek. M
1. What are the rules for using __del__ besides: 'don't use it'. 2. What happens when I SystemExit? __del__ and gc are not invoked when I SystemExit and there's a circular reference - but why? The OS is going to reclaim the memory anyways so why be finicky about circular references - why can't

Re: __del__: when to use it? What happens when you SystemExit/NameError wrt del? Method vs function calls.

2016-03-06 Thread Veek. M
Veek. M wrote: > 1. What are the rules for using __del__ besides: 'don't use it'. > > 2. What happens when I SystemExit? __del__ and gc are not invoked when > I SystemExit and there's a circular reference - but why? The OS is > going to reclaim the memory anywa

Re: __del__: when to use it? What happens when you SystemExit/NameError wrt del? Method vs function calls.

2016-03-07 Thread Veek. M
Steven D'Aprano wrote: > On Monday 07 March 2016 17:13, Veek. M wrote: > >> import foo >> class Bar(object): >> def __del__(self, foo=foo): >> foo.bar()# Use something in module foo >> >> ### Why the foo=foo? import foo, would incre

Pickle __getstate__ __setstate__ and restoring n/w - beazley pg 172

2016-03-07 Thread Veek. M
import socket class Client(object): def __init__(self,addr): self.server_addr = addr self.sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM) self.sock.connect(addr) def __getstate__(self): return self.server_addr def __setstate__(self,value): self.server_addr = value self.s

exec "x = 3; print x" in a - How does it work?

2016-03-08 Thread Veek. M
What is the return value of `exec`? Would that object be then used to iterate the sequence in 'a'? I'm reading this: https://www.python.org/download/releases/2.2.3/descrintro/ -- https://mail.python.org/mailman/listinfo/python-list

Re: exec "x = 3; print x" in a - How does it work?

2016-03-08 Thread Veek. M
Ben Finney wrote: > "Veek. M" writes: > >> What is the return value of `exec`? > > You can refer to the documentation for questions like that. > https://docs.python.org/3/library/functions.html#exec> > >> Would that object be then used to iterate th

Re: exec "x = 3; print x" in a - How does it work?

2016-03-08 Thread Veek. M
Steven D'Aprano wrote: > On Wednesday 09 March 2016 16:27, Veek. M wrote: > >> What is the return value of `exec`? Would that object be then used to >> iterate the sequence in 'a'? I'm reading this: >> https://www.python.org/download/releases/2.2.3/de

Re: Pickle __getstate__ __setstate__ and restoring n/w - beazley pg 172

2016-03-09 Thread Veek. M
dieter wrote: > "Veek. M" writes: > >> import socket >> class Client(object): >> def __init__(self,addr): >> self.server_addr = addr >> self.sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM) >> self.sock.connect(addr) >>

Re: Pickle __getstate__ __setstate__ and restoring n/w - beazley pg 172

2016-03-09 Thread Veek. M
Ian Kelly wrote: > On Wed, Mar 9, 2016 at 2:14 AM, Veek. M wrote: >> what i wanted to know was, x = Client('192.168.0.1') will create an >> object 'x' with the IP inside it. When I do: >> pickle.dump(x) >> pickle doesn't know where in the

Descriptors vs Property

2016-03-11 Thread Veek. M
A property uses the @property decorator and has @foo.setter @foo.deleter. A descriptor follows the descriptor protocol and implements the __get__ __set__ __delete__ methods. But they both do essentially the same thing, allow us to do: foo = 10 del foo x = foo So why do we have two ways of doin

Re: Descriptors vs Property

2016-03-11 Thread Veek. M
Veek. M wrote: > A property uses the @property decorator and has @foo.setter > @foo.deleter. > > A descriptor follows the descriptor protocol and implements the > __get__ __set__ __delete__ methods. > > But they both do essentially the same thing, allow us to do: > foo

Re: Descriptors vs Property

2016-03-11 Thread Veek. M
Ian Kelly wrote: > On Fri, Mar 11, 2016 at 10:59 PM, Veek. M wrote: >> A property uses the @property decorator and has @foo.setter >> @foo.deleter. >> >> A descriptor follows the descriptor protocol and implements the >> __get__ __set__ __delete__ methods. >&

Re: Descriptors vs Property

2016-03-12 Thread Veek. M
Thomas 'PointedEars' Lahn wrote: >> I haven't read the descriptor protocol as yet. > > You should. You should also trim your quotations to the relevant > minimum, and post using your real name. > I don't take advice from people on USENET who DON'T have a long history of helping ME - unless I'

Re: Descriptors vs Property

2016-03-13 Thread Veek. M
Thomas 'PointedEars' Lahn wrote: > Veek. M wrote: > >> Thomas 'PointedEars' Lahn wrote: >>>> I haven't read the descriptor protocol as yet. >>> You should. You should also trim your quotations to the relevant >>> minimum, and p

Re: Descriptors vs Property

2016-03-13 Thread Veek. M
Thomas 'PointedEars' Lahn wrote: >>> Nobility lies in action, not in name. >>> —Surak Someone called Ned.B who i know elsewhere spoke on your behalf. I'm glad to say I like/trust Ned a bit so *huggles* to you, and I shall snip. Also, sorry about the 'Steve' thing - bit shady dragging in

Re: file -SAS

2016-03-19 Thread Adam M
y." | > _o__)--Christopher Hitchens | > Ben Finney I think he meant this: https://pypi.python.org/pypi/sas7bdat And here is what SAS7DAT is https://cran.r-project.org/web/packages/sas7bdat/vignettes/sas7bdat.pdf Judging by name it seams be related to SAS language. Regards Adam M. -- https://mail.python.org/mailman/listinfo/python-list

Python extension using a C library with one 'hello' function

2014-11-04 Thread Veek M
https://github.com/Veek/Python/tree/master/junk/hello doesn't work. I have: hello.c which contains: int hello(void); hello.h To wrap that up, i have: hello.py -> _hello (c extension) -> pyhello.c -> method py_hello() People using this will do: python3.2>> import hello python3.2>> hello.hello() I

Re: generating unique variable name via loops

2014-11-04 Thread Veek M
Fatih Güven wrote: > 4 Kas?m 2014 Sal? 13:29:34 UTC+2 tarihinde Fatih Güven yazd?: >> I want to generate a unique variable name for list using python. >> >> list1=... >> list2=... for x in range(1,10): exec("list%d = []" % x) -- https://mail.python.org/mailman/listinfo/python-list

Re: generating unique variable name via loops

2014-11-04 Thread Veek M
Fatih Güven wrote: > This is okay but i can't use the method ".append" for example > list1.append("abc") works for me -- https://mail.python.org/mailman/listinfo/python-list

Re: Python extension using a C library with one 'hello' function

2014-11-04 Thread Veek M
Søren wrote: > import ctypes Hi, yeah i kind of liked it - still reading the docs though, Beazley has the Python.h solution so I though I'd try that first. -- https://mail.python.org/mailman/listinfo/python-list

Re: Python extension using a C library with one 'hello' function

2014-11-04 Thread Veek M
Jason Swails wrote: > I've submitted a PR to your github repo showing you the changes > necessary to get your module working on my computer. Segfaults :p which is an improvement :) open("./_hello.cpython-32mu.so", O_RDONLY) = 5 read(5, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\300\7\0\0\0

Re: Python extension using a C library with one 'hello' function

2014-11-04 Thread Veek M
Jason Swails wrote: > What operating system are you running this on? It works fine for me on > Linux: Wheezy Debian, Linux deathstar 3.2.0-4-amd64 #1 SMP Debian 3.2.60-1+deb7u3 x86_64 GNU/Linux gcc (Debian 4.7.2-5) 4.7.2 Python 3.2.3 I ran it through gdb - not very useful: (gdb) bt #0 0x00

Re: Python extension using a C library with one 'hello' function

2014-11-04 Thread Veek M
static PyMethodDef hellomethods[] = { {"hello", py_hello, METH_VARARGS, py_hello_doc}, {NULL, NULL, 0, NULL}, }; It's basically the METH_VARARGS field that's giving the problem. Switching it to NULL gives, SystemError: Bad call flags in PyCFunction_Call. METH_OLDARGS is no longer suppor

Re: Python extension using a C library with one 'hello' function

2014-11-04 Thread Veek M
okay got it working - thanks Jason! The 3.2 docs are slightly different. -- https://mail.python.org/mailman/listinfo/python-list

Python, VIM: namespace, scope, life of a python object stuck in a << HERE

2014-11-04 Thread Veek M
If i have two functions: function! foo() python3 << HERE import mylib pass HERE function! bar() python3 << HERE import mylib pass HERE The src says: 1. Python interpreter main program 3. Implementation of the Vim module for Python So, is the python interpreter embedded in vim AND additio

How do i reduce this to a single function - the code is largely similar, just a direction of search toggle.

2014-11-07 Thread Veek M
def jump_to_blockD(self): end = len(self.b) row, col = self.w.cursor while row <= end: try: new_col = self.b[row].index('def') self.w.cursor = row, new_col break except ValueError: pa

Re: How do i reduce this to a single function - the code is largely similar, just a direction of search toggle.

2014-11-07 Thread Veek M
Veek M wrote: > new_col = self.b[row].index('def') > self.w.cursor = row, new_col > new_col = self.b[row].rindex('def') > self.w.cursor = row, new_col There's also the different methods ind

Re: How do i reduce this to a single function - the code is largely similar, just a direction of search toggle.

2014-11-09 Thread Veek M
Ned Batchelder wrote: > On 11/7/14 9:52 AM, Veek M wrote: > and you want to end up on the "def" token, not the "def" in yep, bumped into this :) thanks! -- https://mail.python.org/mailman/listinfo/python-list

functools documentation - help with funny words

2014-11-09 Thread Veek M
https://docs.python.org/3.4/library/functools.html 1. "A key function is a callable that accepts one argument and returns another value indicating the position in the desired collation sequence." x = ['x','z','q']; sort(key=str.upper) My understanding is that, x, y, .. are passed to the key fun

Python: package root, root-node, __init__.py in the package root

2014-11-13 Thread Veek M
I have a package structured like so on the file system: PKG LIBS are stored here: /usr/lib/python3.2/ Pkg-name: foo-1.0.0 1. What is the root directory, or root-node or 'root' of my package? My understanding is that it's: /usr/lib/python3.2/foo-1.0.0/ on the file-system and this is referred to t

Python 3.x (beazley): __context__ vs __cause__ attributes in exception handling

2014-11-13 Thread Veek M
r Traceback. He goes on to say: --- A more subtle example of exception chaining involves exceptions raised within another exception handler. For example: def error(msg): print(m) # Note: typo is intentional (m undefined) try: statements except ValueError as e: error

Re: Python 3.x (beazley): __context__ vs __cause__ attributes in exception handling

2014-11-14 Thread Veek M
It's been answered here: http://stackoverflow.com/questions/26924045/python-3-x-beazley-context-vs- cause-attributes-in-exception-handling?noredirect=1#comment42403467_26924045 -- https://mail.python.org/mailman/listinfo/python-list

uWSGI, nGinx, and python on Wheezy: how do you configure it?

2014-12-16 Thread Veek M
Has anyone got the thing to work? I want to run some python database scripts on nginx. Because that will have a simple web-UI, i decided to go with uWSGI. It's proving to be a massive pain. I found a decent book for nginx and got that bit working. The query gets sent to uWSGI but for some reaso

Re: uWSGI, nGinx, and python on Wheezy: how do you configure it?

2014-12-16 Thread Veek M
Chris Warrick wrote: > This is NOT how uwsgi works! You cannot use plain .py files with it, > and for good reason ? CGI should be long dead. > > What you need to do is, you must write a webapp ? in Flask, for > example. Then you must craft an .ini file that mentions this. **Hi Chris, Could you

<    1   2   3   4   5   6   7   8   9   10   >