Question about ast.literal_eval

2013-05-20 Thread Frank Millman
val(b) True >>> from ast import literal_eval >>> literal_eval(b) ValueError: malformed node or string: <_ast.Compare object at ...> Is there a safe way to do what I want? I am using python 3.3. Thanks Frank Millman -- http://mail.python.org/mailman/listinfo/python-list

Re: Question about ast.literal_eval

2013-05-20 Thread Frank Millman
[Corrected top-posting] >> To: python-list@python.org From: fr...@chagford.com Subject: Question about ast.literal_eval Date: Mon, 20 May 2013 09:05:48 +0200 Hi all I am trying to emulate a SQL check constraint in Python. Quoting from the PostgreSQL docs, "A check constraint is the most generi

Re: Question about ast.literal_eval

2013-05-20 Thread Frank Millman
On 20/05/2013 09:55, Chris Angelico wrote: On Mon, May 20, 2013 at 5:50 PM, Frank Millman wrote: On 20/05/2013 09:34, Carlos Nepomuceno wrote: Why don't you use eval()? Because users can create their own columns, with their own constraints. Therefore the string is user-modifiable,

Re: Question about ast.literal_eval

2013-05-20 Thread Frank Millman
On 20/05/2013 09:55, Carlos Nepomuceno wrote: Why don't you use eval()? Because users can create their own columns, with their own constraints. Therefore the string is user-modifiable, so it cannot be trusted. I understand your motivation but I don'

Re: Question about ast.literal_eval

2013-05-20 Thread Frank Millman
On 20/05/2013 10:07, Frank Millman wrote: On 20/05/2013 09:55, Chris Angelico wrote: Is it a requirement that they be able to key in a constraint as a single string? We have a similar situation in one of the systems at work, so we divided the input into three(ish) parts: pick a field, pick an

Re: Question about ast.literal_eval

2013-05-20 Thread Frank Millman
On 21/05/2013 04:39, matt.newvi...@gmail.com wrote: You might find the asteval module (https://pypi.python.org/pypi/asteval) useful. It provides a relatively safe "eval", for example: >>> import asteval >>> a = asteval.Interpreter() >>> a.eval('x = "abc"') >>> a.eval('x i

Re: Question about ast.literal_eval

2013-05-20 Thread Frank Millman
On 20/05/2013 18:12, Steven D'Aprano wrote: On Mon, 20 May 2013 15:26:02 +0200, Frank Millman wrote: Can anyone see anything wrong with the following approach. I have not definitely decided to do it this way, but I have been experimenting and it seems to work. [...] It seems safe to m

Re: Question about ast.literal_eval

2013-05-20 Thread Frank Millman
On 20/05/2013 18:13, Chris Angelico wrote: On Mon, May 20, 2013 at 11:26 PM, Frank Millman wrote: 0 - for the first entry in the list, the word 'check' (a placeholder - it is discarded at evaluation time), for any subsequent entries the word 'and' or 'or'. 1

Re: Question about ast.literal_eval

2013-05-21 Thread Frank Millman
On 21/05/2013 09:21, Steven D'Aprano wrote: On Tue, 21 May 2013 08:30:03 +0200, Frank Millman wrote: I am not sure I can wrap my mind around mixed 'and's, 'or's, and brackets. Parsers are a solved problem in computer science, he says as if he had a clue what h

Re: Future standard GUI library

2013-06-13 Thread Frank Millman
or no difference whether the client side is running a web browser or a traditional gui interface. On a WAN, there could be a latency problem. Ideally an application should be capable of servicing a local client or a remote client, so it is not easy to find the right balance. Do you have strong

Re: Future standard GUI library

2013-06-13 Thread Frank Millman
"Chris Angelico" wrote in message news:CAPTjJmo+fWsCD3Lb6s+zmWspKzzk_JB=pbcvflbzjgcfxvm...@mail.gmail.com... > On Thu, Jun 13, 2013 at 7:32 PM, Frank Millman wrote: >> I am talking about what I call 'field-by-field validation'. Each field >> could >> h

Re: Future standard GUI library

2013-06-14 Thread Frank Millman
"Chris Angelico" wrote in message news:captjjmq_m4y0uxxt3jqythjj9ckbsvp+z2pgf5v_31xlrgf...@mail.gmail.com... > On Fri, Jun 14, 2013 at 3:39 PM, Frank Millman wrote: >> >> In my case, it is either-or. I do not just do field-by-field validation, >> I >> do

Re: Debugging memory leaks

2013-06-20 Thread Frank Millman
elf._del = DelWatcher(self) Now you can watch the objects as they are created, and then check that they are deleted when you expect them to be. This can help to pinpoint where the memory leak is occurring. HTH Frank Millman -- http://mail.python.org/mailman/listinfo/python-list

Re: Default scope of variables

2013-07-09 Thread Frank Millman
ssion instance. When any of them need any database access, whether for reading or for updating, they execute the following - with db_session as conn: conn.transaction_active = True # this line must be added if updating conn.cur.execute(__whatever__) Now it 'just works'. I don't have the need for save-points - either all updates happen, or none of them do. Frank Millman -- http://mail.python.org/mailman/listinfo/python-list

Re: Default scope of variables

2013-07-09 Thread Frank Millman
"Chris Angelico" wrote in message news:captjjmr4mr0qcgwqxwyvdcz55nuav79vbtt8bjndsdvhrkq...@mail.gmail.com... > On Tue, Jul 9, 2013 at 5:35 PM, Frank Millman wrote: >> I have been following this sub-thread with interest, as it resonates with >> what I am doing in my pr

Re: Default scope of variables

2013-07-09 Thread Frank Millman
"Ian Kelly" wrote in message news:CALwzid=fzgjpebifx1stdbkh8iwltwggwwptphz1ykyg+05...@mail.gmail.com... > On Tue, Jul 9, 2013 at 1:35 AM, Frank Millman wrote: >> When any of them need any database access, whether for reading or for >> updating, they execute the f

Re: Default scope of variables

2013-07-09 Thread Frank Millman
"Ian Kelly" wrote in message news:calwzidnf3obe0enf3xthlj5a40k8hxvthveipecq8+34zxy...@mail.gmail.com... > On Tue, Jul 9, 2013 at 10:07 AM, Ethan Furman wrote: >> You could also do it like this: >> >> def updating(self): >> self.transaction_active = True >> return self > > Ye

Re: Default scope of variables

2013-07-10 Thread Frank Millman
"Ian Kelly" wrote in message news:calwzidk2+b5bym5b+xvtoz8lheyvhcos4v58f8z2o1jb6sa...@mail.gmail.com... > On Tue, Jul 9, 2013 at 11:54 PM, Frank Millman wrote: >> You had me worried there for a moment, as that is obviously an error. >> >> Then I checked my act

Problem with psycopg2, bytea, and memoryview

2013-07-31 Thread Frank Millman
I can hack my program to use tobytes(), but it would add complication, and it would be database-specific. I would prefer a cleaner solution. Does anyone have any suggestions? Versions - Python: 3.3.2 PostgreSQL: 9.2.4 psycopg2: 2.5 Frank Millman -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem with psycopg2, bytea, and memoryview

2013-07-31 Thread Frank Millman
"Antoine Pitrou" wrote in message news:loom.20130731t114936-...@post.gmane.org... > Frank Millman chagford.com> writes: >> >> I have some binary data (a gzipped xml object) that I want to store in a >> database. For PostgreSQL I use a column with datatype 

Re: Problem with psycopg2, bytea, and memoryview

2013-07-31 Thread Frank Millman
"Antoine Pitrou" wrote in message news:loom.20130731t150154-...@post.gmane.org... > Frank Millman chagford.com> writes: >> >> Thanks for that, Antoine. It is an improvement over tobytes(), but i am >> afraid it is still not ideal for my purposes. > > I w

Question about weakref

2012-07-04 Thread Frank Millman
works. So now I am confused. 1. Why do I get the traceback? 2. Can I rely on using weakref.ref, or does that also have some problem that has just not appeared yet? Any advice will be appreciated. BTW, I am using python 3.2.2. Thanks Frank Millman -- http://mail.python.org/mailman/listinfo/python-list

Re: Question about weakref

2012-07-05 Thread Frank Millman
On 05/07/2012 10:46, Dieter Maurer wrote: Frank Millman writes: I have a situation where I thought using weakrefs would save me a bit of effort. Instead of the low level "weakref", you might use a "WeakKeyDictionary". Thanks, Dieter. I could do that. In fact, a WeakS

Re: Question about weakref

2012-07-06 Thread Frank Millman
On 05/07/2012 19:47, Dieter Maurer wrote: Frank Millman writes: I would still like to know why weakref.proxy raised an exception. I have re-read the manual several times, and googled for similar problems, but am none the wiser. In fact, it is documented. Accessing a proxy will raise an

Re: Question about weakref

2012-07-06 Thread Frank Millman
On 06/07/2012 20:12, Ethan Furman wrote: Ian Kelly wrote: def del_b(self, b): for i, x in enumerate(self.array): if b is x: del self.array[i] break Nice work, Ian. I second that. Thanks very much, Ian. Frank -- http://mail.python.org/mailman/listinfo/python-list

Re: Flexible string representation, unicode, typography, ...

2012-08-25 Thread Frank Millman
is saying that he would have preferred that python standardise on 4-byte characters, on the grounds that the saving in memory does not justify the performance overhead. Frank Millman -- http://mail.python.org/mailman/listinfo/python-list

Re: Organisation of python classes and their methods

2012-11-02 Thread Frank Millman
f, ...): [...] def func2(self, ...): [...] AFTER = setup.py - def setup1(self, ...): [...] def setup2(self, ...): [...] main.py - import setup class MyClass: setup1 = setup.setup1 setup2 = setup.setup2 def func1(self, ...): [...] def fun

Re: MySQLdb compare lower

2012-12-13 Thread Frank Millman
name) = LOWER(%s), and it will use the index, so it is not necessary to coerce the data to lower case before storing. Frank Millman -- http://mail.python.org/mailman/listinfo/python-list

py2exe is on Sourceforge list of top growth projects

2012-12-17 Thread Frank Millman
th in the last month. [...] py2exe: A distutils extension to create standalone Windows programs from python scripts. It is 19th on a list of 19, but still, it is nice to see. I wonder if there was any particular reason for that? Frank Millman -- http://mail.python.org/mailman/listinfo/python-list

Re: Need a specific sort of string modification. Can someone help?

2013-01-05 Thread Frank Millman
think is correct - there are 4 dots in the original string. HTH Frank Millman -- http://mail.python.org/mailman/listinfo/python-list

Re: Else statement executing when it shouldnt

2013-01-25 Thread Frank Millman
d it, you want to do something and break. If you do not find it, you want to do something else. for item in iterable: if item == 'something': do_something() break else: # item was not found do_something_else() Not arguing for or against, just saying it is di

Re: ??????????? DOES GOG EXIST

2013-01-26 Thread Frank Millman
On 26/01/2013 18:41, BV BV wrote: DOES GOG EXIST http://www.youtube.com/watch?v=tRMmTbCXXAk&feature=related THANK YOU Did you hear about the dyslexic agnostic insomniac? He lies awake at night wondering if there is a dog. -- http://mail.python.org/mailman/listinfo/python-list

Sorting a hierarchical table (SQL)

2013-01-30 Thread Frank Millman
depth of more than 4 or 5, so I can live with it. However, it is not pretty. I wondered if anyone can suggest a more elegant solution. Thanks Frank Millman -- http://mail.python.org/mailman/listinfo/python-list

Re: Distributing methods of a class across multiple files

2012-01-25 Thread Frank Millman
py - import test2 class Foo: long_method_1 = test2.long_method_1 long_method_2 = test2.long_method_2 Then in Foo I can refer to self.long_method_1(). HTH Frank Millman -- http://mail.python.org/mailman/listinfo/python-list

Re: constraint based killer sudoku solver performance improvements

2012-01-26 Thread Frank Millman
it in the blink of an eye. It also outputs a full trace of the reasoning it used to arrive at a solution. Frank Millman -- http://mail.python.org/mailman/listinfo/python-list

Question about circular imports

2012-02-26 Thread Frank Millman
f that makes any difference. Any advice will be appreciated. Frank Millman -- http://mail.python.org/mailman/listinfo/python-list

Re: Question about circular imports

2012-02-26 Thread Frank Millman
"Frank Millman" wrote in message news:jid2a9$n21$1...@dough.gmane.org... > Hi all > > I seem to have a recurring battle with circular imports, and I am trying > to nail it once and for all. > [...] > > The second solution is - > > in formats/__init__.py &

Re: Question about circular imports

2012-02-26 Thread Frank Millman
"Peter Otten" <__pete...@web.de> wrote in message news:jid424$vfp$1...@dough.gmane.org... > Frank Millman wrote: > > > To cut a long story short, why should circular imports be unavoidable? > > Paths into packages are recipe for desaster. You may end up wit

Re: Question about circular imports

2012-02-26 Thread Frank Millman
> > To avoid the tedious reference, follow this with > read = sound.formats.wavread # choose the identifier you prefer > @Terry and OKB I tried that, but it does not work. a.py /b __init__.py c.py d.py a.py - from b import c c.py - import b.d d.py - import b.c If I run a

Question about sub-packages

2012-02-27 Thread Frank Millman
hen place calls on it directly. I did a quick test and it seems to work. Is this a good idea, or are there any downsides? Thanks Frank Millman -- http://mail.python.org/mailman/listinfo/python-list

Re: Question about sub-packages

2012-02-28 Thread Frank Millman
"Frank Millman" wrote in message news:jii0vo$36t$1...@dough.gmane.org... > Hi all > > This is a follow-up to my recent question about circular imports, but on a > different subject, hence the new thread. > [...] > > If this makes sense, my next thought was,

Trying to understand 'import' a bit better

2012-03-04 Thread Frank Millman
ported twice under different names, with potentially disastrous consequences. Therefore, as I see it, if you are developing a project using scenario 1 above, and then want to change it to scenario 2, you have to go through the entire project and change all import references by prepending the package name. Have I got this right? Frank Millman -- http://mail.python.org/mailman/listinfo/python-list

Re: Reading Live Output from a Subprocess

2012-04-06 Thread Frank Millman
- the digits 0 to 4 displayed with delays of 1 second. Running sub_proc2 gives exactly the same output. This is using python 3.2.2 on Windows Server 2003. Frank Millman -- http://mail.python.org/mailman/listinfo/python-list

Difference between 'imp' and 'importlib'

2012-04-20 Thread Frank Millman
also works, and does not reload the module. So my question is, is there any practical difference between the two approaches? What about 'There should be one-- and preferably only one --obvious way to do it'? Frank Millman -- http://mail.python.org/mailman/listinfo/python-list

Minor issue with sqlite3 and datetime

2012-04-29 Thread Frank Millman
is - microseconds = int('{:0<6}'.format(timepart_full[1])) Any chance of this being accepted? Frank Millman -- http://mail.python.org/mailman/listinfo/python-list

Some posts do not show up in Google Groups

2012-04-29 Thread Frank Millman
OE, so they are being accepted. I send to the group gmane.comp.python.general. Does anyone know a reason for this, or have a solution? Frank Millman -- http://mail.python.org/mailman/listinfo/python-list

Re: Some posts do not show up in Google Groups

2012-04-30 Thread Frank Millman
On Apr 30, 8:20 am, Frank Millman wrote: > Hi all > > For a while now I have been using Google Groups to read this group, but on > the odd occasion when I want to post a message, I use Outlook Express, as I > know that some people reject all messages from Google Groups due to t

OT, but very funny

2011-06-29 Thread Frank Millman
out of cookie use, now web site operators need to ask for permission before they implement any cookies. So the opt out system has been replaced with an opt in system. Enjoy Frank Millman -- http://mail.python.org/mailman/listinfo/python-list

Re: subprocess & isql

2011-07-15 Thread Frank Millman
reading.Thread(target=read_stdout, args=(sql_stdout,)).start() s.seek(0) sql_stdin.writelines(s.readlines()) s.close() sql_stdin.close() HTH Frank Millman -- http://mail.python.org/mailman/listinfo/python-list

Convert '165.0' to int

2011-07-21 Thread Frank Millman
rst, it does work - int(float(x)) 165 Is there a short cut, or must I do this every time (I have lots of them!) ? I know I can write a function to do this, but is there anything built-in? Thanks Frank Millman -- http://mail.python.org/mailman/listinfo/python-list

Re: Convert '165.0' to int

2011-07-21 Thread Frank Millman
On Jul 21, 11:47 am, Leo Jay wrote: > On Thu, Jul 21, 2011 at 5:31 PM, Frank Millman wrote: > > > Hi all > > > I want to convert '165.0' to an integer. > > > The obvious method does not work - > > >>>> x = '165.0' > >&g

Re: Convert '165.0' to int

2011-07-21 Thread Frank Millman
On Jul 21, 11:53 am, Thomas Jollans wrote: > On 21/07/11 11:31, Frank Millman wrote: > > > Hi all > > > I want to convert '165.0' to an integer. > > Well, it's not an integer. What does your data look like? How do you > wish to convert it to int?

Re: Convert '165.0' to int

2011-07-21 Thread Frank Millman
> > [1] See separate thread on apparent inconsisteny in timeit timings.- Hide > quoted text - > I must have done something wrong - it is consistent now. Here are the results - C:\Python32\Lib>timeit.py "int(float('165.0'))" 10 loops, best of 3: 3.51 usec per loop C:\Python32\Lib>timeit.py

Re: Convert '165.0' to int

2011-07-21 Thread Frank Millman
On Jul 21, 10:00 pm, Terry Reedy wrote: > On 7/21/2011 10:13 AM, Grant Edwards wrote: > > > On 2011-07-21, Web Dreamer  wrote: > >> Leo Jay a ?crit ce jeudi 21 juillet 2011 11:47 dans > > >> int(x.split('.')[0]) > > >> But, the problem is the same as with int(float(x)), the integer number is > >>

Question about timeit

2011-07-21 Thread Frank Millman
("165.0"))' 1000 loops, best of 3: 0.0887 usec per loop I ran them both twice just to be sure. The first two use double-quote marks to surround the statement, and single-quote marks to surround the literal inside the statement. The second two swap the quote marks around.

Re: Question about timeit

2011-07-22 Thread Frank Millman
On Jul 22, 8:37 am, Stefan Behnel wrote: > Frank Millman, 22.07.2011 08:06: > > > > > > > I mentioned in a recent post that I noticed an inconsistency in timeit, and > > then reported that I must have made a mistake. > > > I have now identified my prob

Re: Question about timeit

2011-07-22 Thread Frank Millman
On Jul 22, 10:34 am, Stefan Behnel wrote: > Thomas Rachel, 22.07.2011 10:08: > > > > > > > Am 22.07.2011 08:59 schrieb Frank Millman: > > >> My guess is that it is something to do with the console, but I don't > >> know what. If I get time over t

Re: Question about timeit

2011-07-22 Thread Frank Millman
On Jul 22, 2:43 pm, Thomas Jollans wrote: > On 22/07/11 14:30, Frank Millman wrote: > > > > > > > This is what I get after modifying timeit.py as follows - > > >     if args is None: > >         args = sys.argv[1:] > > +       print(args) > > &

Re: Convert '165.0' to int

2011-07-22 Thread Frank Millman
On Jul 22, 9:59 pm, Terry Reedy wrote: > On 7/22/2011 1:55 AM, Frank Millman wrote: > > > As the OP, I will clarify what *my* requirement is. This discussion > > has gone off at various tangents beyond what I was asking for. > > Typical. Don't worry about it ;-). &

Re: Convert '165.0' to int

2011-07-23 Thread Frank Millman
On Jul 23, 9:42 am, Chris Angelico wrote: > On Sat, Jul 23, 2011 at 4:53 PM, Frank Millman wrote: > > The problem with that is that it will silently ignore any non-zero > > digits after the point. Of course int(float(x)) does the same, which I > > had overlooked. > >

Re: Convert '165.0' to int

2011-07-23 Thread Frank Millman
On Jul 23, 10:23 am, Steven D'Aprano wrote: > Frank Millman wrote: > > To recap, the original problem is that it would appear that some third- > > party systems, when serialising int's into a string format, add a .0 > > to the end of the string. I am trying

Re: Convert '165.0' to int

2011-07-24 Thread Frank Millman
On Jul 23, 5:12 pm, Billy Mays wrote: > On 7/23/2011 3:42 AM, Chris Angelico wrote: > > > > > int(s.rstrip('0').rstrip('.')) > > Also, it will (in?)correct parse strings such as: > > '16500' > > to 165. > > -- > Bill True enough. If I really wanted to be 100% safe, how ab

Re: Convert '165.0' to int

2011-07-24 Thread Frank Millman
On Jul 24, 9:34 am, Steven D'Aprano wrote: > Frank Millman wrote: > > If I really wanted to be 100% safe, how about this - > > >     def get_int(s): > >         if '.' in s: > >             num, dec = s.split('.', 1) > >  

Re: Convert '165.0' to int

2011-07-24 Thread Frank Millman
On Jul 24, 10:07 am, Chris Angelico wrote: > On Sun, Jul 24, 2011 at 5:58 PM, Frank Millman wrote: > >  if int(dec) != 0: > > to > >    if [_ for _ in list(dec) if _ != '0']: > > if dec.rtrim('0')!='': > > ChrisA I think you mean

Re: Convert '165.0' to int

2011-07-24 Thread Frank Millman
On Jul 23, 8:28 pm, rantingrick wrote: > On Jul 23, 1:53 am, Frank Millman wrote: > > >-- > > The ideal solution is the one I sketched out earlier - modify python's > > 'int' fu

Re: Convert '165.0' to int

2011-07-24 Thread Frank Millman
On Jul 24, 10:53 am, Ben Finney wrote: > Frank Millman writes: > > I know I am flogging a dead horse here, but IMHO, '165', '165.', > > '165.0', and '165.00' are all valid string representations of the > > integer 165.[1] > &g

Re: Convert '165.0' to int

2011-07-24 Thread Frank Millman
On Jul 25, 2:04 am, Gregory Ewing wrote: > Frank Millman wrote: > > I know I am flogging a dead horse here, but IMHO, '165', '165.', > > '165.0', and '165.00' are all valid string representations of the > > integer 165.[1] >

Re: Is this a safe use of eval?

2011-02-24 Thread Frank Millman
Thanks, Paul and Peter. It seemed like a good idea at the time. Thank you for straightening me out. Frank -- http://mail.python.org/mailman/listinfo/python-list

Re: 2to3 chokes on bad character

2011-02-24 Thread Frank Millman
"John Machin" wrote: On Feb 23, 7:47 pm, "Frank Millman" wrote: [snip lots of valuable info] The issue is not that 2to3 should handle this correctly, but that it should give a more informative error message to the unsuspecting user. Your Python 2.x code should be TE

Re: 2to3 chokes on bad character

2011-02-24 Thread Frank Millman
"Peter Otten" <__pete...@web.de> wrote John Machin wrote: Your Python 2.x code should be TESTED before you poke 2to3 at it. In this case just trying to run or import the offending code file would have given an informative syntax error (you have declared the .py file to be encoded in UTF-8 but

Re: Is this a safe use of eval?

2011-02-24 Thread Frank Millman
"Christian Heimes" wrote Am 24.02.2011 10:01, schrieb Peter Otten: How do you prevent that a malicious source sends you my_string = 'calc_area(__import__("os").system("rm important_file") or 100, 200)' instead? By using something like http://code.activestate.com/recipes/496746-restricted

Problem with python 3.2 and circular imports

2011-02-27 Thread Frank Millman
t works, but it seems to be defeating the purpose of PEP 328, which I thought was an improvement. Any comments or suggestions will be appreciated. Frank Millman -- http://mail.python.org/mailman/listinfo/python-list

Re: issue on internal import in a package

2011-02-27 Thread Frank Millman
both windows and linux. It works using python 2.6. I can fix it by changing a.py from 'import b' to 'from . import b'. As I understand it, the reason is that python 3.x will no longer look for an absolute import in the current package - it will only look in sys.path. Frank Millman -- http://mail.python.org/mailman/listinfo/python-list

Re: Problem with python 3.2 and circular imports

2011-02-27 Thread Frank Millman
"Ben Finney" wrote in message news:87aahh6401@benfinney.id.au... "Frank Millman" writes: Assume the following structure - main.py /pkg __init__.py mod1.py mod2.py main.py from pkg import mod1 mod1.py import mod2 mod2.py import mod1 What a

Re: issue on internal import in a package

2011-02-27 Thread Frank Millman
"人言落日是天涯,望极天涯不见家" wrote in message news:fa94323b-d859-4599-b236-c78a22b3d...@t19g2000prd.googlegroups.com... On Feb 27, 9:22 pm, "Frank Millman" wrote: This behavior is by design or just a bug for Python3.x ? Definitely by design. Have a look at PEP 328 - http://www

Re: issue on internal import in a package

2011-02-27 Thread Frank Millman
"人言落日是天涯,望极天涯不见家" wrote in message news:9529d52b-01b2-402c-a0a0-1e9240038...@l14g2000pre.googlegroups.com... On Feb 27, 9:38 pm, "Frank Millman" wrote: "人言落日是天涯,望极天涯不见家" wrote in message news:fa94323b-d859-4599-b236-c78a22b3d...@t19g2000prd.googlegroup

Re: Problem with python 3.2 and circular imports

2011-02-27 Thread Frank Millman
"Steven D'Aprano" wrote in message news:4d6a56aa$0$29972$c3e8da3$54964...@news.astraweb.com... On Sun, 27 Feb 2011 12:08:12 +0200, Frank Millman wrote: Assume the following structure - main.py /pkg __init__.py mod1.py mod2.py main.py from pkg impor

Re: Problem with python 3.2 and circular imports

2011-03-04 Thread Frank Millman
t runs with no errors. I even put a couple of print statements (or must I call them print functions now) into the modules being imported, and the messages do appear, so the modules are being imported. HTH Frank Millman -- http://mail.python.org/mailman/listinfo/python-list

Fun with 'str' and 'bytes'

2011-03-04 Thread Frank Millman
ot;' + session_id + b'"')) It works, but it is not pretty. Is there a more elegant solution? Thanks Frank Millman -- http://mail.python.org/mailman/listinfo/python-list

Re: Fun with 'str' and 'bytes'

2011-03-05 Thread Frank Millman
On Mar 4, 6:40 pm, nn wrote: > On Mar 4, 7:32 am, "Frank Millman" wrote: > > > Hi all > > > I want to create a cookie containing a session id. In python 2.6 I had the > > following - > > > from __future__ import unicode_literals > > session_id

Re: Problem with python 3.2 and circular imports

2011-03-06 Thread Frank Millman
"Rafael Durán Castañeda" wrote... Thank you for your answer Frank, I think I've found the problem. I was calling modules from inside subpackages, and I need to use them from outside, so I have package in PYTHONPATH. is that correct? But now I have another question: Can I execute an script insi

Re: organizing many python scripts, in a large corporate environment.

2011-03-13 Thread Frank Millman
in the search path. In your scripts you have to 'import' the package first, to ensure that these lines get executed. My 2c Frank Millman -- http://mail.python.org/mailman/listinfo/python-list

py32 on windows - input() includes trailing \r

2011-04-20 Thread Frank Millman
Hi all On linux, python 3.2 - x = input() xyz len(x) 3 x 'xyz' on windows, python 3.2 - x = input() xyz len(x) 4 x 'xyz\r' Is this expected behaviour? Frank Millman -- http://mail.python.org/mailman/listinfo/python-list

Re: py32 on windows - input() includes trailing \r

2011-04-20 Thread Frank Millman
"Peter Otten" <__pete...@web.de> wrote in message news:iomla6$p8f$1...@dough.gmane.org... Frank Millman wrote: On linux, python 3.2 - x = input() xyz len(x) 3 x 'xyz' on windows, python 3.2 - x = input() xyz len(x) 4 x 'xyz\r' Is this ex

Re: what is payload

2017-09-07 Thread Frank Millman
when you create your own class, you can give it any attributes you like, and call them whatever you like. If you changed 'payload' in the above to 'xyz', it would work exactly the same. Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: Old Man Yells At Cloud

2017-09-19 Thread Frank Millman
, in new pence, came to four figures. She then, talking to herself, did the next bit of the calculation. 'Lets see, there are 100 new pence in a pound, so divide the total by 100, ...'. She worked the whole thing out using just pencil and paper, and then when she had written down the result, exclaimed 'Oh, it’s the same!'. Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: Easy way to get a list of tuples.

2017-09-21 Thread Frank Millman
.append(('a', 'b', 'c')) x.append(('p', 'q', 'r')) x [('a', 'b', 'c'), ('p', 'q', 'r')] Does this help? Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: Textwrap doesn't honour NO-BREAK SPACE

2017-09-28 Thread Frank Millman
0ZZZ sed do euismod tempor incididunt' ... ' ut labore et dolore magna aliqua.') print(textwrap.fill(text, 59)) Lorum ipsum dolor sit amet, consectetur adipiscing elit ZZZ ZZZ sed do euismod tempor incididunt ut labore et dolore magna aliqua. It seems to have been fixed. Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: Textwrap doesn't honour NO-BREAK SPACE

2017-09-29 Thread Frank Millman
por incididunt ut labore et dolore magna aliqua. C:\Users\User>py -3.6 aib\aib\test_db100.py Lorum ipsum dolor sit amet, consectetur adipiscing elit ZZZ ZZZ sed do euismod tempor incididunt ut labore et dolore magna aliqua. It confirms that the problem was there in 3.5, but is fixed in 3.6

Re: The "loop and a half"

2017-10-04 Thread Frank Millman
T are necessary because it does not use indentation or braces to terminate blocks, it uses keywords. Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Why does asyncio.wait_for() need a timeout?

2017-11-23 Thread Frank Millman
the program hangs. If I add a timeout to the second one, it behaves the same as the first one. Is there a reason for this? I am using version 3.6.0. Thanks Frank Millman import asyncio from itertools import count async def counter1(): cnt = count(1) try: while True

Re: Why does asyncio.wait_for() need a timeout?

2017-11-24 Thread Frank Millman
"Frank Millman" wrote in message news:ov5v3s$bv7$1...@blaine.gmane.org... Below is a simple asyncio loop that runs two background tasks. [...] Both take an optional timeout. If I use the first method without a timeout, the cancellation completes and the loop stops. If I use

Re: Why does asyncio.wait_for() need a timeout?

2017-11-24 Thread Frank Millman
"Ian Kelly" wrote in message news:calwzidmrpfrr5mrejjyz+bdgtqlwy-sp+a_zc6zq7ebaz9g...@mail.gmail.com... On Fri, Nov 24, 2017 at 6:31 AM, Frank Millman wrote: > "Frank Millman" wrote in message news:ov5v3s$bv7$1...@blaine.gmane.org... > >> Below is a s

Re: While, If, Count Statements

2017-11-28 Thread Frank Millman
he 'while' loop? If not, give it a shot and see what happens. Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: While, If, Count Statements

2017-11-28 Thread Frank Millman
"Cai Gengyang" wrote in message news:a8335d2c-1fb9-4ba9-b752-418d19e57...@googlegroups.com... On Tuesday, November 28, 2017 at 4:18:04 PM UTC+8, Frank Millman wrote: > "Cai Gengyang" wrote in message > news:c2dfc9c4-3e16-480c-aebf-553081775...@googlegroups.com... &g

Re: Please tell me how to execute python file in Ubuntu by double clicking on file. (Posting On Python-List Prohibited)

2017-12-09 Thread Frank Millman
7;.pgp'. He did so, tried again, and said 'Ah, now it works'. Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Dunder variables

2018-01-08 Thread Frank Millman
upon? Thanks Frank Millman -- https://mail.python.org/mailman/listinfo/python-list

Re: Dunder variables

2018-01-09 Thread Frank Millman
"Peter Otten" wrote in message news:p31v3m$pji$1...@blaine.gmane.org... Frank Millman wrote: > Hi all > > I have read that one should not call dunder methods in application code. > > Does the same apply to dunder variables? I am thinking of the instance > attr

Re: Dunder variables

2018-01-09 Thread Frank Millman
"Frank Millman" wrote in message news:p321rb$9ct$1...@blaine.gmane.org... "Peter Otten" wrote in message news:p31v3m$pji$1...@blaine.gmane.org... Frank Millman wrote: > Hi all > > I have read that one should not call dunder methods in application code. >

Re: Dunder variables

2018-01-09 Thread Frank Millman
"Steven D'Aprano" wrote in message news:p32g4v$v88$2...@blaine.gmane.org... On Tue, 09 Jan 2018 11:28:03 +0200, Frank Millman wrote: > I have a class call Context containing only data, not methods. Instances > are passed around a lot in my application, with various method

  1   2   3   4   5   6   7   8   >