Re: test-ignore

2024-02-15 Thread Tony Oliver via Python-list
On Thursday 15 February 2024 at 21:16:22 UTC, E.D.G. wrote:
> Test - ignore February 15, 2024 
> 
> Test post to see if my Newsgroup post program is working.

Aim your test messages at alt.test, please.
-- 
https://mail.python.org/mailman/listinfo/python-list


Imports and dot-notation

2023-08-09 Thread Oliver Schinagl via Python-list

Dear list,


First a disclaimer, I am a python novice ;) so apologies beforehand for 
any incorrect terms and use thereof :)


I have a question about the preferred/pythonic way dealing with imports. 
But let me start by giving a little bit of an example (which lead me to 
this question).


Looking at a python projects code and repository layout, we see the 
following directory structure.



/project/core
/project/components/module1
...
/project/components/moduleN
/projects/util

(this is far from complete, but enough to help paint a picture.

Some modules import other modules, and I see (at the very least) two 
(kind of three?) different ways of doing so.


`from project.components.module1 import function1, function2 as func, 
CONST1, CONST2 as CONST`


or maybe even (which has as an advantage that it becomes clear which 
namespace something belongs to


`from project.components.module1 import function1, function2 as 
module1_function2, CONST1, CONST2 as MODULE1_CONST2`


but then it really just becomes personal preference, as the number of 
characters saved on typing is almost negative (due to having a more 
complex import).



but also the dot notation being used

`from project.components import module1`

where obviously the functions are invoked as `module1.function1` etc

I hope the above is clear enough from an example.


Simply put, which of the two would be considered cleaner and more pythonic?

Now for a bit more thought, looking at PEP8, we notes about imports, but 
sadly PEP8 does not state which method is better/preferred. While 
obviously in the end, it's always the maintainers choice in what they 
prefer, so are tabs vs spaces and PEP8 is opinionated about that too (in 
a good way, even though I'm not a fan :p).


Likewise, if we look at PEP20, there's quite a few 'guidelines' that 
suggest the dot-notation. To name a few (opinionated) examples (but note 
I am just using PEP20 as a helper to give some arguments, I know some 
people feel strongly against pep20 :p):


* Beautiful is better than ugly.
  - Personally, I think the dot notation is more beautiful, but I 
understand that some people find the short notation more beautiful and 
less of an eye sore ;)


* Explicit is better than implicit.
  - To me, this is a strong point. Being more explicit is always 
better, using the dot notation (if though it's not doing the WHOLE path) 
is a nice balance in being explicit enough. Code readability comes from 
being more explicit (without being to terse of course).


* Simple is better than complex.
* Flat is better than nested.
  -  I think having more flat and simple imports, and (while more 
characters to potentially type in the invocation) more readable 
invocations would be better?


* Readability counts.
  - The dot notation seems to help in readability. For those unfamiliar 
(or less familiar) with a code base, it becomes incredibly clear where a 
something comes from (WITHOUT having to rely on IDE's; sure you can 
hover over something and see that the IDE has hopefully worked out where 
something came from, but this doesn't work when just reading a page of 
code, you aren't going to hover over everything and remember all that 
context).


* In the face of ambiguity, refuse the temptation to guess.
  - I'd argue this is almost self-explanatory, not using dot-notation 
makes it more ambiguous where something is coming from.


* There should be one-- and preferably only one --obvious way to do it.
  - This is where my confusion/question obviously comes from, as 
there's multiple ways of doing it, so maybe PEP8 (or a new one) should 
more strongly favor one?


* Namespaces are one honking great idea -- let's do more of those!
  - Basically, this question/proposal would 'force/nudge' you into 
writing more with namespaces by using the namespace as prefix.



So what IS the preferred/more pythonic/recommended way to deal with imports?

Why was this not mentioned in PEP8?

Is it worth while to introduce a new PEP or amend PEP8?


For what it's worth, hallucinating chatgpt/google bard both say the same 
about this topic, that within the python community, it is generally 
preferred and a good idea to use dot-notation. But how correct are they lol.



Thank you for reading,

Olliver



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


Re: Single line if statement with a continue

2022-12-18 Thread Tony Oliver
On Saturday, 17 December 2022 at 23:58:11 UTC, avi.e...@gmail.com wrote:
> Is something sort of taboo when using something like a computer language to 
> write a program?

With what else would you write a program?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Selenium py3.8+ DepreciationWarnings - where to find doc to update code?

2021-10-13 Thread Tony Oliver


On Wednesday, 13 October 2021 at 16:16:46 UTC+1, jkk wrote:
> Selenium 3.141+ 
> python 3.8+ 
> ubuntu 20.04 or windows 10 
> 
> I'm trying to upgrade code from py3.6+ to py3.8+ and I'm getting several 
> DepreciationWarnings. 
> 
> Can someone point me to where I can find the documentation that explains how 
> to to remedy these warnings. What are the new preferred coding practices? 
> 
> For example, here is a "DepreciationWarning" that I figured out: 
> 
> py3.6+ 
> from selenium import webdriver 
> browser = browser = webdriver.Firefox() 
> browser.get(url) 
> tables = browser.find_elements_by_tag_name("table") 
> 
> 
> py3.8+ 
> from selenium import webdriver 
> from selenium.webdriver.common.by import By 
> browser = browser = webdriver.Firefox() 
> browser.get(url) 
> tables = browser.find_elements(By.TAG_NAME, "table") 
> or 
> tables = browser.find_elements(By.XPATH, "//table")

I cannot help you with your immediate problem but am intrigued to discover what 
your “browser = browser = “ idiom does that differs from “browser = 
“.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue45417] Enum creation non-linear in the number of values

2021-10-08 Thread Oliver Margetts


New submission from Oliver Margetts :

Creating large enums takes a significant amount of time. Moreover this appears 
to be nonlinear in the number of entries in the enum. Locally, importing a 
single python file and taking this to the extreme:

 1000 entries - 0.058s
1 entries - 4.327s

This is partially addressed by https://bugs.python.org/issue38659 and I can 
confirm that using `@_simple_enum` does not have this problem. But it seems 
like that API is only intended for internal use and the 'happy path' for 
user-defined enums is still not good.

Note that it is not simply parsing the file / creating the instances, it is to 
do with the cardinality. Creating 100 enums with 100 entries each is far faster 
than a single 1 entry enum.

--
files: huge.py
messages: 403512
nosy: olliemath
priority: normal
severity: normal
status: open
title: Enum creation non-linear in the number of values
type: performance
versions: Python 3.10, Python 3.11, Python 3.7
Added file: https://bugs.python.org/file50332/huge.py

___
Python tracker 
<https://bugs.python.org/issue45417>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Understanding the working mechanis of python unary arithmetic operators.

2021-10-02 Thread Tony Oliver
On Saturday, 2 October 2021 at 13:48:39 UTC+1, hongy...@gmail.com wrote:
> On Saturday, October 2, 2021 at 4:59:54 PM UTC+8, ju...@diegidio.name wrote: 
> > On Saturday, 2 October 2021 at 10:34:27 UTC+2, hongy...@gmail.com wrote: 
> > > See the following testings: 
> > > 
> > > In [24]: a=3.1415926535897932384626433832795028841971 
> > > In [27]: -a 
> > > Out[27]: -3.141592653589793 
> > You've never heard of floating-point? Double precision has 53 significant 
> > bits of mantissa, corresponding approximately to 16 decimal digits. 
> > 
> >  
> > > In [17]: ~-+1 
> > > Out[17]: 0 
> > << The unary ~ (invert) operator yields the bitwise inversion of its 
> > integer argument. The bitwise inversion of x is defined as -(x+1). It only 
> > applies to integral numbers or to custom objects that override the 
> > __invert__() special method. >> 
> > 
> >  
> > > I'm very puzzled by these operators. Any hints will be highly 
> > > appreciated. 
> > Try and read the proverbial manual: that's truly a fundamental skill...
> Thank you for your explanation. Then what about the following questions?: 
> 
> 1. Should `+' and `-' be classified as binary operators or unary operators?

Both.  See sections 6.6 and 6.7 of the documentation at
https://docs.python.org/3/reference/expressions.html

> As we all know, `a + b', and `a - b' are the normal ways we do basic 
> arithmetic operations. 

Really?  Don't you ever write something like "x = -y"?
Or do you habitually write "x = 0 - y" or "x = 0.0 - y"?

> 2. See the following testings: 
> 
> In [20]: bool(int(True)) 
int(True) -> 1
bool(1) -> True
> Out[20]: True 
> 
> In [21]: bool(~int(True)) 
int(True) -> 1
~1 -> -2
bool(-2) -> True
> Out[21]: True 
> 
> In [22]: bool(~~int(True)) 
int(True) -> 1
~1 -> -2  # these two operations
~(-2) -> 1# cancel each other out
bool(1) -> True
> Out[22]: True 
> 
> In [23]: bool(~~~int(True)) 
Because two consecutive bit-inversions cancel each other out;
this is just a complicated re-statement of operation [21], above
> Out[23]: True 
> 
> In [24]: bool(int(False)) 
int(False) -> 0
bool(0) -> False
> Out[24]: False 
> 
> In [25]: bool(~int(False)) 
int(False) -> 0
~0 -> -1
bool(-1) -> True
> Out[25]: True 
> 
> In [26]: bool(~~int(False)) 
Again, two consecutive inversions cancel each other out
so this is just an over-complicated re-statement of [24]
> Out[26]: False 
> 
> In [27]: bool(~~~int(False)) 
Likewise, this is the equivalent of re-stating [25]
> Out[27]: True 
> 
> Why can’t/shouldn't we get something similar results for both `True' and 
> `False' in the above testings? 

Sorry, I can't parse that.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue34788] ipaddress module fails on rfc4007 scoped IPv6 addresses

2021-05-02 Thread Oliver Giles


Change by Oliver Giles :


--
nosy: +ohwgiles
nosy_count: 10.0 -> 11.0
pull_requests: +24512
pull_request: https://github.com/python/cpython/pull/25824

___
Python tracker 
<https://bugs.python.org/issue34788>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44012] IPv6Address.exploded does not support interface name (scope id)

2021-05-02 Thread Oliver Giles


Change by Oliver Giles :


--
keywords: +patch
pull_requests: +24511
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/25824

___
Python tracker 
<https://bugs.python.org/issue44012>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue44012] IPv6Address.exploded does not support interface name (scope id)

2021-05-02 Thread Oliver Giles


New submission from Oliver Giles :

IPv6 addresses may contain a scope id, for example "fe80::1%eth0".

These are usually required for link-local addresses.

bpo-34788 added support for scoped IPv6 addresses, but missed the
"exploded" method:

>>> import ipaddress
>>> ipaddress.IPv6Address('fe80::1%eth0').exploded
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python3.9/ipaddress.py", line 394, in exploded
return self._explode_shorthand_ip_string()
  File "/usr/lib/python3.9/ipaddress.py", line 1824, in 
_explode_shorthand_ip_string
ip_int = self._ip_int_from_string(ip_str)
  File "/usr/lib/python3.9/ipaddress.py", line 1705, in _ip_int_from_string
raise AddressValueError("%s in %r" % (exc, ip_str)) from None
ipaddress.AddressValueError: Only hex digits permitted in '1%eth0' in 
'fe80::1%eth0'

--
components: Library (Lib)
messages: 392740
nosy: ohwgiles
priority: normal
severity: normal
status: open
title: IPv6Address.exploded does not support interface name (scope id)

___
Python tracker 
<https://bugs.python.org/issue44012>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32146] multiprocessing freeze_support needed outside win32

2021-03-27 Thread Oliver Newman


Change by Oliver Newman :


--
nosy: +onew

___
Python tracker 
<https://bugs.python.org/issue32146>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42879] SystemError from class 'int'

2021-01-10 Thread Jason Oliver


Jason Oliver  added the comment:

I will submit the bug report to the pygame bug tracker.

--

___
Python tracker 
<https://bugs.python.org/issue42879>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42879] SystemError from class 'int'

2021-01-09 Thread Jason Oliver


New submission from Jason Oliver :

This is my first bug report so I hope that this is correctly formatted. I am 
learning how to use pygame and encountered the following error:
SystemError:  returned a result with an error set

I googled the error message and came across the following answer on 
stackoverflow:
https://stackoverflow.com/a/53796516

This stated that the problem could exist within the implementation of python 
and that I should file a bug report here.

I am using the following software installed through pip/pip3:
Python 3.8.4
pygame 2.0.1
OS Edition: Windows 10 Pro
OS Version: 20H2
OS build: 19042.685

The bug can be reproduced deterministically.

--
files: Movement.py
messages: 384743
nosy: jollyoliver657
priority: normal
severity: normal
status: open
title: SystemError from class 'int'
versions: Python 3.8
Added file: https://bugs.python.org/file49731/Movement.py

___
Python tracker 
<https://bugs.python.org/issue42879>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41636] distutils.util.strtobool documented behaviour

2020-08-25 Thread Graham Oliver


New submission from Graham Oliver :

Here is the text 

https://docs.python.org/3.6/distutils/apiref.html#distutils.util.strtobool

Convert a string representation of truth to true (1) or false (0).

True values are y, yes, t, true, on and 1; false values are n, no, f, false, 
off and 0. Raises ValueError if val is anything else.

I wondered what would happen with 'FALSE' i.e. upper case. It appears to behave 
the same way as 'false'. In fact case does not seem to be an issue, so 'FaLsE' 
will return 0 as well.

So a note that this function is independent of case may be helpful

--
assignee: docs@python
components: Documentation
messages: 375902
nosy: Graham.Oliver, docs@python
priority: normal
severity: normal
status: open
title: distutils.util.strtobool documented behaviour
versions: Python 3.6

___
Python tracker 
<https://bugs.python.org/issue41636>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: How to create an Excel app that runs Python?

2020-03-24 Thread oliver
Use the win32com library to interact with Excel via COM. Although the
learning curve is a little steeper it's not too bad and works great. I used
this technique to control ARENA with Python through its COM API to run a
whack of simulations (1000-1), then used python to gather the results,
and used win32com from python to finally inject the data into Excel and get
it to generate charts and tables that could be used by stakeholders without
access to python.

Oliver Schoenborn
  || Cloud Application Engineer, Owner || Sentian Cloud Computing Inc.
  || Ottawa, ON, Canada || +1-613-552-4466 (mobile)
  || oli...@sentianse.com




On Tue, Mar 24, 2020 at 7:16 AM  wrote:

> I have the following scenario:
>
> I have created lots of python files that I use to calculate a Cashflow
> model, when I run these files I get a beautiful pandas DataFrame that
> contains my final model. My mission is to show this table to the rest of
> the company in a friendly format ("Excel") and they need to be able to
> generate this table themselves from Excel, using the Python script I
> created ("the idea is that they open an excel file that has some type of
> dashboard and a form that they need to fill in, once they fill it in and
> press "Go" or "Run" or something like that, these parameters will be sent
> to the Python script to generate this final pandas DataFrame. Finally this
> DataFrame needs to be displayed/pasted in the Excel sheet that they
> initially opened)
>
>
> The problems:
>
> The company needs to be able to run this model, but the users, apart from
> me, use Excel and they can't open up a Jupyter notebook or VSC to run the
> code. They can't even install Python on their machines (or at least that is
> not ideal)
>
>
> My Attempts:
>
> I am currently using "xlwings" to run Python within Excel, although it
> requires that the user has Python and xlwings installed and has added the
> xlwings "Addin", which is not an ideal solution at all.
>
> I am thinking about using Dash, I don't know if it is what I need since I
> haven't looked into it that much yet (I have been trying to make it work on
> xlwings first)
>
>
>
> If you have any suggestions on how to do this, I would really appreciate
> that.
>
> Thank you
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Would you be interested in this Python open source project?

2019-10-12 Thread oliver
There are tons of projects that need help, I recommend that instead of
re-inventing the wheel as there are enough choices out there re cicd and
very likely you will find that your goal of 10/90 is unrealistic.

Have a look at codetriage.com, and github has a feature that allows you to
search for projects that need help.

Another major advantage of helping an existing project is that you will be
seeing how others write python code so you will learn best practices faster
(dont kid yourself, if you do it on your own the code you write now you
will find horrible in a year, and you certainly will not be interested in
rewriting it!).

Keep up the good work!

On Wed., Oct. 9, 2019, 08:35 Simon Connah,  wrote:

>
> On 08/10/2019 15:05, Bill Deegan wrote:
> > You might just consider working with the BuildBot project to add support
> > for lighter weight build workers.
> > Re-Re-Re-inventing the wheel is almost always wasted effort.
>
> Buildbot looks good. I'll check to make sure its open source license is
> compatible with the Affero General Public License version 3. On the
> other hand I do have a desire to build something similar myself just to
> get the hang of things like this. Thank you for your reply.
>
> > On Tue, Oct 8, 2019 at 8:33 AM Rhodri James 
> wrote:
> >
> >> On 08/10/2019 11:22, Simon Connah wrote:
> >>> I'm posting this message as a way to gauge interest in the project and
> >>> to see if it is worth moving forward with. There are probably hundreds
> >>> of CI/CD tools out there and many more general devops tools but what I
> >>> want to build is a CI/CD tool that ONLY supports Python 3.6 or greater
> >>> and only runs on one Linux distribution (my preference is Ubuntu). This
> >>> way configuration would be much more simple than the vast majority of
> >>> devops tools which try to support every programming language that is
> >>> popular (or so it seems) on many different Linux distributions and even
> >>> Windows and macOS.
> >>>
> >>> My theory is that if you limit the devops tool to a very limited
> >>> subsection of the available options the system will be easier to
> >>> configure for users, more stable, easier to patch bugs in and generally
> >>> just be a better all around things for Python developers.
> >>>
> >>> I'd love to hear some feedback on the idea.
> >>>
> >> I think your reasoning is sound.  I probably wouldn't make a lot of use
> >> of it, but I live in Embedded Systems land where it's notoriously hard
> >> to do CI off the target silicon.  Other people living in more tractable
> >> problem spaces will probably be more enthusiastic.
> >>
> >> --
> >> Rhodri James *-* Kynesim Ltd
> >> --
> >> https://mail.python.org/mailman/listinfo/python-list
> >>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue34717] docs: disable numbered sections for stdlib in html

2019-04-26 Thread Oliver Too, Eh?


Oliver Too, Eh?  added the comment:

As someone who is only now making the transition from Python 2 to Python 3, 
losing the numbering in the documentation on the Python Standard Library slows 
down my navigation when looking through the high-level contents.  

Given that the position of sections hasn't drifted much between versions, being 
able to treat the sections like chapters of a book affords faster access when I 
can quickly identify my position in the page without having to look at the 
scrollbar, provided my operating system even displays one when I am not 
actively scrolling.  Knowing that there are roughly 40 top-level sections in 
the library means I can find something I know to be in the middle much more 
quickly from its number (plus or minus version drift) and those of its local 
surroundings than by its overall position in the page.  Moreover, losing this 
feature can only be mitigated by search or "find in page" provided I remember 
modules and their contents by name, correctly spelled.

I appreciate the overall cleaner appearance as sections become heavily nested 
that is addressed by this enhancement.  I do however respectfully disagree with 
the choice of doing this at the expense of top level ordering.

--
nosy: +Oliver Too Eh?

___
Python tracker 
<https://bugs.python.org/issue34717>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36727] python 3.6+ docs use ul tags instead of ol tags

2019-04-25 Thread Oliver Too, Eh?


New submission from Oliver Too, Eh? :

Documentation contents are ordered, and readers familiar with the section 
numbers/ordering from the Python 2 or Python 3.5 documentation will have an 
easier time transitioning to Python 3.6 or later if the sections remain 
numbered.

--
assignee: docs@python
components: Documentation
messages: 340866
nosy: Oliver Too, Eh?, docs@python
priority: normal
severity: normal
status: open
title: python 3.6+ docs use ul tags instead of ol tags
versions: Python 3.6, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 
<https://bugs.python.org/issue36727>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue35278] [security] directory traversal in tempfile prefix

2019-04-14 Thread Oliver Bestwalter


Oliver Bestwalter  added the comment:

I am not sure if this justifies a new issue so I add this here.

The suffix parameter can also be used for a traversal attack. It is possible to 
completely clobber anything in dir and prefix (at least on Windows).

e.g. calling mkdtemp or NamedTemporaryFile with these paramers ...

dir=r"C:\tmp",
prefix="pre",
suffix="../../../../../../../../../gotcha"

Will result in a directory or file being created at C:/gotcha.

I also wonder if this would justify adding a warning to the documentation for 
all existing Python versions?

Quoting from the documentation of mkstemp 
(https://docs.python.org/3/library/tempfile.html#tempfile.mkstemp):

> If prefix is specified, the file name will begin with that prefix; otherwise, 
> a default prefix is used.
>
> If dir is specified, the file will be created in that directory [...]

As both claims are rendered untrue when using suffix in the above described way 
I think this should be amended.

--
nosy: +obestwalter

___
Python tracker 
<https://bugs.python.org/issue35278>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Your IDE's?

2019-03-25 Thread oliver
Been using IDEs for 30 years (turbopascal anyone?): by far, PyCharm (used
for 5 years so far). Then VS Code (one year). I still use both. Vs Code is
faster to load, uses less mem and has a simplicity about it that is
appealing.

BUT vscode has similar speed to pycharm once started (actually might even
be slower), and although very capable, is not anything as capable as
pycharm when it comes to refactoring, inspections, configurability,
debugging, find/replace, integration with Git (way better than the 2
leading Git plugins for vs code), and various other capabilities you take
for granted in pycharm like finding unused imports, deep integration with
pytest, and many more.

On Mon., Mar. 25, 2019, 17:41 John Doe,  wrote:

>
> What is your favorite Python IDE?
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Multiprocessing vs subprocess

2019-03-13 Thread oliver
With multiprocessing you can take advantage of multi-core processing as it
launches a separate python interpreter process and communicates with it via
shared memory (at least on windows). The big advantage of multiprocessing
module is that the interaction between processes is much richer than
subprocess: subprocess is limited to pipes (unless you build your own
alternate comms mechanism), whereas multiprocessing takes care of
marshalling python objects and transporting them to the other processes.
This can be huge in some applications, like we were using it to run batch
monte carlo simulations where we needed to pass simulation related
datastructures, would have been a pain with subprocess.


On Tue, Mar 12, 2019 at 12:30 PM Schachner, Joseph <
joseph.schach...@teledyne.com> wrote:

> Re: " My understanding (so far) is that the tradeoff of using
> multiprocessing is that my manager script can not exit until all the work
> processes it starts finish. If one of the worker scripts locks up, this
> could be problematic. Is there a way to use multiprocessing where processes
> are launched independent of the parent (manager) process?"
>
> I just want to point out that subprocess (which uses the operating system
> to start another processes, to run whatever you say - doesn't have to be
> Python running another script, can be an .exe)  does not have that
> restriction.  The subprocess call can be blocking (the caller waits), or
> not.   If not the caller can do whatever it wants including decide not to
> wait forever, and it can even exit.
>
> Of course, if one of the processes you launched is locked up that is a
> problem all by itself, even thought the manager can exit.
>
> --- Joseph S.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: the python name

2019-01-02 Thread Ben Oliver

On 18-12-31 22:39:04, pritanshsahs...@gmail.com wrote:
why did you kept this name? i want to know the history behind this and 
the name of this snake python.


It's named after Monty Python [0].

[0] https://docs.python.org/3/tutorial/appetite.html


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to host python micro-services on windows machine?

2018-12-10 Thread oliver
You might also find that
https://www.raymond.cc/blog/keep-application-running-by-automatically-rerun-when-closed/
lists some useful options.

But most solutions I read about for Windows seem to be based on its
Services subsystem and its ability to restart and control how many time to
retry.

On Mon., Dec. 10, 2018, 07:17 oliver,  wrote:

> There are a few options in https://stackoverflow.com/q/7629813/869951,
> esp the third answer.
>
> On Mon., Dec. 10, 2018, 02:41 ,  wrote:
>
>> I am developing some micro-services in python. I want to host that
>> micro-services on windows machine. For ubuntu I am using Supervisord. What
>> should I use for Windows ? Please help
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
> --
> Oliver Schoenborn
>   || Cloud Application Engineer, Owner || Sentian Software Engineering ||
> Ottawa, ON, Canada
>   || +1-613-552-4466 (mobile) || @schollii2 (Twitter) || schoenborno (
> Skype)
>   || LinkedIn <https://linkedin.com/in/oliver-schoenborn> || StackOverFlow
> <https://stackoverflow.com/users/869951/oliver> || CodeProject
> <https://www.codeproject.com/Articles/schollii#Tip> || GitHub
> <https://github.com/schollii>
>
> --
Oliver Schoenborn
  || Cloud Application Engineer, Owner || Sentian Software Engineering ||
Ottawa, ON, Canada
  || +1-613-552-4466 (mobile) || @schollii2 (Twitter) || schoenborno (Skype)
  || LinkedIn <https://linkedin.com/in/oliver-schoenborn> || StackOverFlow
<https://stackoverflow.com/users/869951/oliver> || CodeProject
<https://www.codeproject.com/Articles/schollii#Tip> || GitHub
<https://github.com/schollii>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to host python micro-services on windows machine?

2018-12-10 Thread oliver
There are a few options in https://stackoverflow.com/q/7629813/869951, esp
the third answer.

On Mon., Dec. 10, 2018, 02:41 ,  wrote:

> I am developing some micro-services in python. I want to host that
> micro-services on windows machine. For ubuntu I am using Supervisord. What
> should I use for Windows ? Please help
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
Oliver Schoenborn
  || Cloud Application Engineer, Owner || Sentian Software Engineering ||
Ottawa, ON, Canada
  || +1-613-552-4466 (mobile) || @schollii2 (Twitter) || schoenborno (Skype)
  || LinkedIn <https://linkedin.com/in/oliver-schoenborn> || StackOverFlow
<https://stackoverflow.com/users/869951/oliver> || CodeProject
<https://www.codeproject.com/Articles/schollii#Tip> || GitHub
<https://github.com/schollii>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python in the news

2018-07-25 Thread oliver
Along the same lines but focused on one of the companies mentioned in the
Economist article is one by Bloomberg :
https://www.bloomberg.com/news/articles/2018-06-14/citi-wants-analysts-to-add-python-to-list-of-languages-on-resume

On Mon, Jul 23, 2018, 12:35 Rich Shepard,  wrote:

>The lead article in science section and technology section of this
> week's
> 'The Economist' is about Python:
> <
> https://www.economist.com/science-and-technology/2018/07/21/python-has-brought-computer-programming-to-a-vast-new-audience
> >
>
> Enjoy,
>
> Rich
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
Oliver Schoenborn
  || Cloud Application Engineer, Owner || Sentian Software Engineering ||
Ottawa, ON, Canada
  || +1-613-552-4466 (mobile) || @schollii2 (Twitter) || schoenborno (Skype)
  || LinkedIn <https://linkedin.com/in/oliver-schoenborn> || StackOverFlow
<https://stackoverflow.com/users/869951/oliver> || CodeProject
<https://www.codeproject.com/Articles/schollii#Tip> || GitHub
<https://github.com/schollii>
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue25433] whitespace in strip()/lstrip()/rstrip()

2018-04-11 Thread Oliver Urs Lenz

Oliver Urs Lenz <oliver.urs.l...@gmail.com> added the comment:

Slightly tangential, but it would be great if the documentation of lstrip() and 
rstrip() could include an equivalent definition in terms of re.sub(), e.g.:

lstrip(foo) == re.sub(r'(?u)\A\s*', '', foo)
rstrip(foo) == re.sub(r'(?u)\s*\Z', '', foo)

(Or whatever else is correct.)

--
nosy: +oulenz

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue25433>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33181] SimpleHTTPRequestHandler shouldn't redirect to directories with code 301

2018-03-30 Thread Oliver Urs Lenz

Oliver Urs Lenz <oliver.urs.l...@gmail.com> added the comment:

Yes, but Apache's redirect can be turned off, whereas this can't, so it seems 
unnecessarily limiting to force this on users. Note that most of the motivation 
given by Apache doesn't apply here: with my proposed simplification, both types 
of indices would still be served whether the path contains a trailing slash or 
not.

--

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33181>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33181] SimpleHTTPRequestHandler shouldn't redirect to directories with code 301

2018-03-30 Thread Oliver Urs Lenz

Oliver Urs Lenz <oliver.urs.l...@gmail.com> added the comment:

In fact, since we use os.path.join, we could remove that condition altogether:

if os.path.isdir(path):
for index in "index.html", "index.htm":
index = os.path.join(path, index)
if os.path.exists(index):
path = index
break

--

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33181>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33181] SimpleHTTPRequestHandler shouldn't redirect to directories with code 301

2018-03-30 Thread Oliver Urs Lenz

Oliver Urs Lenz <oliver.urs.l...@gmail.com> added the comment:

That would definitely take the sting out of that permanent redirect. But I am 
still wondering why we redirect at all. Why not leave redirects to the user and 
do:

if os.path.isdir(path):
if not path.endswith('/'):
path = path + '/'
for index in "index.html", "index.htm":
index = os.path.join(path, index)
if os.path.exists(index):
path = index
break

--

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33181>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33181] SimpleHTTPRequestHandler shouldn't redirect to directories with code 301

2018-03-29 Thread Oliver Urs Lenz

New submission from Oliver Urs Lenz <oliver.urs.l...@gmail.com>:

SimpleHTTPRequestHandler.send_head() has this bit:

if os.path.isdir(path):
parts = urllib.parse.urlsplit(self.path)
if not parts.path.endswith('/'):
# redirect browser - doing basically what apache does
self.send_response(HTTPStatus.MOVED_PERMANENTLY)

https://github.com/python/cpython/blob/521995205a2cb6b504fe0e39af22a81f785350a3/Lib/http/server.py#L676

I think there are two issues here:
1) why should the server return a redirect code here, and not (in the code that 
immediately follows) when it serves an index file?
2) code 301 (permanent redirect) is really unforgiving, browsers like Firefox 
and Chrome will permanently cache the redirect, making it essentially 
impossible to undo if you do not control the client, and not trivial even if 
you do. This will probably not change on the browser-side, general opinion 
seems to be that limited caching should either be specified in the response 
header or that a different redirect code should be sent back.
https://lists.w3.org/Archives/Public/ietf-http-wg/2017OctDec/thread.html#msg363

Therefore I would like to propose that preferably,
- no redirect code be sent back, or else that
- a different redirect code be sent back, or else that
- no-caching or a time limit be added to the header

(This may require that send_head check for index files instead)

--
components: Library (Lib)
messages: 314663
nosy: oulenz
priority: normal
severity: normal
status: open
title: SimpleHTTPRequestHandler shouldn't redirect to directories with code 301
versions: Python 3.6

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue33181>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Simple graphic library for beginners

2018-01-10 Thread oliver
Pyqt without hesitation.

   - I've used it in full-fledged desktop app (120k LOC) and it's just
   awesome, so well documented, versatile, and you can learn gradually
   (starting with their simpler tablewidget then later move to their
   tableview/model for added flexibility).
   - Qt is moving so fast into iot and automotive and is so popular on
   desktops, that it's a skill that gets noticed on resumes or in interviews
   (i'm talking from first hand experience).
   - It is available in multiple languages like Java, Go and C#, although I
   have not used those wrappers (the PyQt wrapper is based on sip, whereas
   these other ones are not, so I have no idea about stability etc).
   - the community is huge, there are powerful tools like pytest.qt plugin
   for unit testing GUI, pycharm IDE integrates with it.
   - there is dual license based on LGPL and commercial, with reasonable
   costs, perfect for learning/startup then eventually (if that's the goal
   medium or long term) distribute/sell.

Oliver

On Wed, 10 Jan 2018 at 10:46 bartc <b...@freeuk.com> wrote:

> On 10/01/2018 14:55, Antoon Pardon wrote:
> > On 10-01-18 13:40, Jan Erik Moström wrote:
> >> I'm looking for a really easy to use graphic library. The target users
> >> are teachers who have never programmed before and is taking a first
> >> (and possible last) programming course.
> >>
> >> I would like to have the ability to draw lines, circles, etc. Nothing
> >> fancy, as little window management as possible (possible buttons),
> >> perhaps simple events like button presses or clicks on canvas - think:
> >> making simple diagrams or simple figures. Cross-platform
> >>
> >>
> >> Yes, I know about tkinter.
> >>
> >> Yes, I know about various block languages like Scratch but they are
> >> not relevant in this case.
> >>
> >> Any suggestions?
> >>
> >> = jem
> >
> > cairo?
>
> Isn't that output only? (And not necessarily to a screen, but to an
> image or PDF for example.)
>
> So that no interaction is possible.
>
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
Oliver
My StackOverflow contributions
My CodeProject articles
My Github projects
My SourceForget.net projects
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [OT] Python and Excel

2017-12-18 Thread oliver
That would be amazing. I still have nightmares of when I had to create this
big options analysis VBA program in Excel 2007.

On Mon, Dec 18, 2017, 14:21 MRAB, <pyt...@mrabarnett.plus.com> wrote:

> Those who use Excel might find this interesting:
>
> Microsoft Considers Adding Python as an Official Scripting Language to
> Excel
>
> https://www.bleepingcomputer.com/news/microsoft/microsoft-considers-adding-python-as-an-official-scripting-language-to-excel/
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
Oliver
My StackOverflow contributions
My CodeProject articles
My Github projects
My SourceForget.net projects
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python GUI application embedding a web browser - Options?

2017-10-10 Thread oliver
Can you elaborate what is not sufficient with Qt's web components?
http://doc.qt.io/qt-5/topics-web-content.html. This allows for HTML, CSS,
Javascript, via either native C++ Qt, QML, or Python (PyQt) or mixtures of
these 3. That said, I have not yet used Qt`s web engine so I don`t know how
full-featured it is, how robust, etc. I have used PyQt for several years in
production grade project and it is very solid and well documented and easy
to program with and easy to write tests for.
Oliver

On Mon, 9 Oct 2017 at 12:59 fpp <nntp@spamgourmet.com> wrote:

> Paul Moore <p.f.mo...@gmail.com> said :
>
> > On 9 October 2017 at 04:25,  <douglashf@gmail.com> wrote:
> >> Did you find out the answer for that?
> >
> > Nothing much beyond the pointer to PyQt (which basically said "a lot
> > of the info on the web is out of date" so I should check the latest
> > docs). I didn't take it much further, though, as it was a hobby
> > project and the learning curve for PyQt (any GUI framework, really)
> > was a bit high for the amount of spare time I had at the time.
> >
> > Paul
>
> Have you looked at CEFpython ?
> It seems to work with all major GUIs (Qt, wx, Tk, gtk..)
> https://github.com/cztomczak/cefpython/tree/master/examples
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
Oliver
My StackOverflow contributions
My CodeProject articles
My Github projects
My SourceForget.net projects
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: A question on modification of a list via a function invocation

2017-08-14 Thread oliver
It is not a global because accessing an item of a list does not change
whether it is global or local. It would only be global if you declared it
global via a "global" statement. Can you give an example, that would help
determine the issue.

On Mon, 14 Aug 2017 at 16:06 Mok-Kong Shen <mok-kong.s...@t-online.de>
wrote:

> Am 14.08.2017 um 21:53 schrieb Ned Batchelder:
> > On 8/14/17 3:21 PM, Mok-Kong Shen wrote:
> >> Am 14.08.2017 um 20:50 schrieb Ned Batchelder:
> >>> On 8/14/17 2:21 PM, Mok-Kong Shen wrote:
> >>>> I ran the attached program and got the following output:
> >>>>
> >>>> [1, 2, 3]
> >>>> [3, 6, 9]
> >>>>
> >>>> I don't understand why the modification doesn't work in the case of
> >>>> test() but does work in the case of test1().
> >>>>
> >>>> Thanks for your help in advance.
> >>>>
> >>>> M. K. Shen
> >>>>
> >>>> 
> >>>>
> >>>> def test(alist):
> >>>> alist=[3,6,9]
> >>>> return
> >>>>
> >>>> def test1(alist):
> >>>> alist[0],alist[1],alist[2]=3,6,9
> >>>> return
> >>>>
> >>>> ss=[1,2,3]
> >>>> test(ss)
> >>>> print(ss)
> >>>> test1(ss)
> >>>> print(ss)
> >>>
> >>> This reassigns the name alist:  alist = [3, 6, 9].   That changes the
> >>> local variable, but cannot affect the caller's variables.
> >>>
> >>> This leaves alist as the same object, but reassigns its elements,
> >>> mutating the list:  alist[0] = 3
> >>>
> >>> This talk has more details: https://nedbatchelder.com/text/names1.html
> >>
> >> I could more or less understand that in test() alist is interpreted as
> >> local but in the extended program below in test2() I first write the
> >> same as in test1(), after which I logically assume that the name alist
> >> is now known as global and then I write alist=[30,60,90] but that
> >> doesn't have any effect globally, since I get the output:
> >>
> >> [1, 2, 3]
> >> [3, 6, 9]
> >> [3, 6, 9]
> >>
> >> Could you please explain that?
> >>
> >> M. K. Shen
> >> -
> >>
> >> def test(alist):
> >>alist=[3,6,9]
> >>return
> >>
> >> def test1(alist):
> >>alist[0],alist[1],alist[2]=3,6,9
> >>return
> >>
> >> def test2(alist):
> >>alist[0],alist[1],alist[2]=3,6,9
> >>alist=[30,60,90]
> >>return
> >>
> >> ss=[1,2,3]
> >> test(ss)
> >> print(ss)
> >> test1(ss)
> >> print(ss)
> >> test2(ss)
> >> print(ss)
> >
> > Your test2 function first mutates the caller's list by assigning
> > alist[0]=3, then it rebinds the local name alist to be a new list.  So
> > the caller's list is now [3, 6, 9].
>
> Sorry for my poor knowledge. After the line alist[0]..., what is the
> status of the name alist? It's now a global name, right? So why in the
> line following that the name alist would suddenly be interpreted as
> local? I can't yet fully comprehend the logic behind that.
>
> M. K. Shen
>
>
>   .
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
Oliver
My StackOverflow contributions
My CodeProject articles
My Github projects
My SourceForget.net projects
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Proposed new syntax

2017-08-10 Thread oliver
Then what about

[x for x in (0, 1, 2, 3, 4, 66, 7, 8, 9, 10)
while x < 10
if x % 2 == 0]

Seems it should be valid and [0, 2, 4].

On Thu, Aug 10, 2017, 14:06 Jussi Piitulainen, <
jussi.piitulai...@helsinki.fi> wrote:

> Steve D'Aprano writes:
>
> > Every few years, the following syntax comes up for discussion, with
> > some people saying it isn't obvious what it would do, and others
> > disagreeing and saying that it is obvious. So I thought I'd do an
> > informal survey.
> >
> > What would you expect this syntax to return?
> >
> > [x + 1 for x in (0, 1, 2, 999, 3, 4) while x < 5]
>
> [1, 2, 3]
>
> > For comparison, what would you expect this to return? (Without
> > actually trying it, thank you.)
> >
> > [x + 1 for x in (0, 1, 2, 999, 3, 4) if x < 5]
>
> [1, 2, 3, 4, 5]
>
> > How about these?
> >
> > [x + y for x in (0, 1, 2, 999, 3, 4) while x < 5 for y in (100, 200)]
>
> [100, 200, 101, 201, 102, 202]
> >
> > [x + y for x in (0, 1, 2, 999, 3, 4) if x < 5 for y in (100, 200)]
>
> [100, 200, 101, 201, 102, 202, 103, 203, 104, 204]
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
Oliver
My StackOverflow contributions
My CodeProject articles
My Github projects
My SourceForget.net projects
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question

2017-07-31 Thread oliver
On Mon, Jul 31, 2017, 17:33 Sonja Williams via Python-list, <
python-list@python.org> wrote:

>
>
>
>
> Good Day,
>
> I have decided to learn more about programming so I picked up the book
> Beginning Programming by Matt Telles.  After following the directions
> verbatim and going to the Python site to download the latest version 3,
> which is what the book recommended, I keep getting the following error
> message when running my first script. I am using Windows 7 - 64 bit
>
> " python is not recognized as an internal or external command, operable
> program, or batch file".
>
>
> I am at the end of chapter 3 attempting to run the following script.
>
> python ch3_1.py  which should return What is your name?
>
>
> What am I doing wrong?
>

The window in which you are typing the command to run the script is called
a "shell". The error you are getting means the shell does not have a
built-in command (like cd or dir or help) called "python", nor can it
find "python.bat" or "python.exe" in any of the folders known to it. To
check which folders are known to the shell, type "path" in it; the
semicolon-separated list of folders that this prints will likely be missing
the Python folder.

I presume you installed python 3.6? There is an option to add the Python
folder to path as part of the installation, so you might want to uninstall
python, then re-run the installer this time paying close attention to this
configuration option. For example in Python 3.5 installer the option is
called "Add Python 3.5 to path", see the first snapshot at
https://docs.python.org/3/using/windows.html.

With this option in effect, the output from the "path" command will include
the Python folder. So when you type "python ch3.py" the shell will see a
python.exe in Python folder and run it and all will work!

Oliver


>
>
>
>
>
> Sonja Williams
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
Oliver
My StackOverflow contributions
My CodeProject articles
My Github projects
My SourceForget.net projects
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Scala considering significant indentation like Python

2017-05-22 Thread oliver
Any nesting beyond third level should be strong candidate for refactoring.
Soon after you do that, big surprise, refactored block gets better
documented, gets used elsewhere, becomes testable on its own, etc. I.e. if
structure is not obvious from indentation alone, refactoring is the proper
solution, not braces.

Also deeply nested structures tend to involve variables in the deepest
levels that are also used in the outer levels, making the scope of
variables harder to manage (leading to similar bugs as result from use of
global variables).

So languages that do not require braces for code blocks encourage
refactoring, and hence clearer code structure, separation of concerns,
isolation of namespaces, etc.

On Mon, May 22, 2017, 09:31 Cholo Lennon <chololen...@hotmail.com> wrote:

> On 22/05/17 00:53, Steve D'Aprano wrote:
> > The creator of Scala, Martin Odersky, has proposed introducing
> Python-like
> > significant indentation to Scala and getting rid of braces:
> >
> >  I was playing for a while now with ways to make Scala's syntax
> >  indentation-based. I always admired the neatness of Python syntax
> >  and also found that F# has benefited greatly from its optional
> >  indentation-based syntax, so much so that nobody seems to use
> >  the original syntax anymore.
> >
> > https://github.com/lampepfl/dotty/issues/2491
> >
> >
> >
>
>  From the link:
>
> "Impediments
>
> What are the reasons for preferring braces over indentations?
>
> Provide visual clues where constructs end. With pure indentation based
> syntax it is sometimes hard to tell how many levels of indentation are
> terminated at some point... "
>
> I am a huge python fan (but also a C++ and Java fan) and I agree with
> Scala creator, sometimes the readability is complicated. So, more often
> than I would like to, I end up missing the braces :-O
>
>
> --
> Cholo Lennon
> Bs.As.
> ARG
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
Oliver
My StackOverflow contributions
My CodeProject articles
My Github projects
My SourceForget.net projects
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: type hinting backward compatibility with python 3.0 to 3.4

2017-05-21 Thread oliver
Could something like this support forward declarations without the hackish
use of strings?

On Sun, 21 May 2017 at 12:01 justin walters <walters.justi...@gmail.com>
wrote:

> On Sun, May 21, 2017 at 2:38 AM, Chris Angelico <ros...@gmail.com> wrote:
>
> > On Sun, May 21, 2017 at 7:29 PM, bartc <b...@freeuk.com> wrote:
> > >
> > > They might be /created/ at runtime, but it's a pretty good bet that the
> > name
> > > A in this declaration:
> > >
> > >   class A...
> > >
> > > is the name of a class. The question in Python, as always, is whether
> an
> > A
> > > used as the name of a type in a type, is still this same A. And
> > presumably
> > > such a type hint can precede the declaration of A.
> > >
> > > In fact the declaration of A might be in a different module from its
> use
> > in
> > > a type hint, which means that, in the CPython byte-code compiler
> anyway,
> > it
> > > is not visible at compile-time, when type hints could best be put to
> good
> > > effect.
> >
> > That isn't a problem - mypy follows imports. It'd be pretty useless if
> > it didn't :)
> >
> > > Furthermore, both A, and the type-hinting code, might be conditional.
> So
> > > that on Tuesdays, A is a class, the rest of the week it's the name of a
> > > module.
> >
> > Or, more plausible example: on platforms that have a system-provided
> > source of entropy, random.random is an instance of SystemRandom, but
> > on those that don't, it's an instance of DeterministicRandom with an
> > arbitrarily-chosen seed. The two will have slightly different APIs.
> >
> > > Python doesn't make things easy.
> >
> > Python makes things flexible, which has a cost.
> >
> > ChrisA
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> >
>
> Perhaps a good way to distinguish between a class that can be used as a
> type and a class
> that cannot be used as a type would be to require some sort of dunder
> method be
> defined on the type class. At first I was thinking `__type__`, but then I
> remembered that's
> already in use. maybe something as simple as `__hint__`.
>
> That or only allow classes that inherit from `type` to be used in type
> annotations.
>
> I'm just spit balling ideas here.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
Oliver
My StackOverflow contributions
My CodeProject articles
My Github projects
My SourceForget.net projects
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: type hinting backward compatibility with python 3.0 to 3.4

2017-05-19 Thread oliver
makes sense that the RHS of the equality (deafult value) should be
evaluated before the LHS (arg name + type) but if you hadn't pointed out
that something was not as you expected, i would not have paid attention and
anticipated as you did. Then again RHS vs LHS might have nothing to do with
the reason that the interpreter evaluates in this order :)

On Fri, 19 May 2017 at 21:59 Chris Angelico <ros...@gmail.com> wrote:

> On Sat, May 20, 2017 at 11:42 AM, Gregory Ewing
> <greg.ew...@canterbury.ac.nz> wrote:
> > Steve D'Aprano wrote:
> >>
> >> On Fri, 19 May 2017 11:35 pm, Edward Ned Harvey (python) wrote:
> >>
> >>> I *thought* python 3.0 to 3.4 would *ignore* annotations, but it
> >>> doesn't...
> >>
> >>
> >> Why would you think that?
> >
> >
> > Ever since Guido retconned the purpose of annotations to be
> > for static type hinting *only*, it would make more sense for
> > the interpreter to ignore them, or at least not evaluate them
> > immediately at run time (since it would avoid all the problems
> > of forward references, etc).
> >
> > So I can see how someone relying on the principle of least
> > surprise might assume that.
>
> They're function metadata. What would the principle of least surprise
> say about this?
>
> print("Spam")
> def func(arg: print("Foo") = print("Quux")):
> print("Blargh")
> print("Fred")
> func()
> print("Eggs")
>
> What should be printed, and in what order?
>
> Actually, Python does violate least-surprise in one area here. There's
> one message that gets printed "out of order" compared to my
> expectation. I wonder if it's the same one that other people will be
> surprised at.
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
Oliver
My StackOverflow contributions
My CodeProject articles
My Github projects
My SourceForget.net projects
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue30272] distutils.version.LooseVersion's compare raises exception in corner-case

2017-05-04 Thread Oliver Smith

Changes by Oliver Smith <smartt...@mailinator.com>:


--
components: +Distutils
nosy: +dstufft, merwok
type:  -> behavior

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue30272>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30272] distutils.version.LooseVersion's compare raises exception in corner-case

2017-05-04 Thread Oliver Smith

New submission from Oliver Smith:

This should return True and not raise an exception:

>>> from distutils.version import LooseVersion
>>> LooseVersion("22.7-r1") < LooseVersion("22.7.3-r1")
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python3.6/distutils/version.py", line 52, in __lt__
c = self._cmp(other)
  File "/usr/lib/python3.6/distutils/version.py", line 337, in _cmp
if self.version < other.version:
TypeError: '<' not supported between instances of 'str' and 'int'
>>>

Tested with Python 3.6.1.

--
messages: 293009
nosy: ollieparanoid2
priority: normal
severity: normal
status: open
title: distutils.version.LooseVersion's compare raises exception in corner-case
versions: Python 3.6

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue30272>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: TypeVar single constraint not allowed, why?

2017-05-04 Thread oliver
On Wed, 3 May 2017 at 18:36 Gregory Ewing <greg.ew...@canterbury.ac.nz>
wrote:

> Ned Batchelder wrote:
> > Couldn't you simply annotate it as ": type", without using a TypeVar?
>
> Not if you want to constrain two types to be the same type.
>
>
Exactly! It would be a lot more expressive to write something like (with
Type assumed imported from typing module):

def func(a: type, b: type) -> Tuple[Type(a), Type(b)]:
...

This will not work because a and b are not globals. I could use strings but
this is a hack / language wart as far as I'm concerned (the language should
be extended so we don't have to resort to a lowly string). I suppose I
could do:

def func(a: type, b: type) -> Tuple[TypeVar['a'], TypeVar['b']]:
...

but this is not pythonic (not clean, simple), and too easy to have typo.
Same with forward declarations, where a class references itself in an
annotation: we should not have to resort to a string to express this, very
clunky and hacky.



> --
> Greg
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
Oliver
My StackOverflow contributions
My CodeProject articles
My Github projects
My SourceForget.net projects
-- 
https://mail.python.org/mailman/listinfo/python-list


TypeVar single constraint not allowed, why?

2017-05-02 Thread oliver
The documentation for typing.TypeVar gives these two examples:

T = TypeVar('T')  # Can be anything
A = TypeVar('A', str, bytes)  # Must be str or bytes

I was suprised to find out that the following does not work, exception says
that TypeVar is not definable with only one constraint:

A = TypeVar('A', type)  # Must be a type, like class Foo, etc (rather
than an instance of a type)

The TypeVar source code explicitely forbids only one type constraint, what
is the rationale behind this?

For those who wonder, my function parameter expects a type rather than an
instance of a type, and returns a type.

-- 
Oliver
My StackOverflow contributions
My CodeProject articles
My Github projects
My SourceForget.net projects
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue29821] importing module shutil executes file 'copy.py'

2017-03-15 Thread Oliver Etchebarne (drmad)

New submission from Oliver Etchebarne (drmad):

I didn't research this issue further. Create a file 'test.py', and write only 
'import shutil'. Then create a file 'copy.py' in the same directory, and write 
something inside, like 'print ("OH NO")'.

When you run test.py, 'copy.py' is executed, and prints the string. Tested with 
python 3.5 and 3.6. Works as expected (test.py doing nothing) in python 2.7

--
messages: 289681
nosy: Oliver Etchebarne (drmad)
priority: normal
severity: normal
status: open
title: importing module shutil executes file 'copy.py'
type: behavior
versions: Python 3.5

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29821>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Announcement: TLSv1.2 will become mandatory in the future for Python.org Sites

2017-01-13 Thread oliver
When I run this per email from my work laptop,

python3 -c "import urllib.request,json;
print(json.loads(urllib.request.urlopen('
https://www.howsmyssl.com/a/check').read())['tls_version'])"

I get the following traceback:

C:\...>python -c "import urllib.request,json;
print(json.loads(urllib.request.url
w.howsmyssl.com/a/check').read())['tls_version'])"
Traceback (most recent call last):
File "c:\Python35\lib\urllib\request.py", line 1254, in do_open
h.request(req.get_method(), req.selector, req.data, headers)
File "c:\Python35\lib\http\client.py", line 1106, in request
self._send_request(method, url, body, headers)
File "c:\Python35\lib\http\client.py", line 1151, in _send_request
self.endheaders(body)
File "c:\Python35\lib\http\client.py", line 1102, in endheaders
self._send_output(message_body)
File "c:\Python35\lib\http\client.py", line 934, in _send_output
self.send(msg)
File "c:\Python35\lib\http\client.py", line 877, in send
self.connect()
File "c:\Python35\lib\http\client.py", line 1260, in connect
server_hostname=server_hostname)
File "c:\Python35\lib\ssl.py", line 377, in wrap_socket
_context=self)
File "c:\Python35\lib\ssl.py", line 752, in __init__
self.do_handshake()
File "c:\Python35\lib\ssl.py", line 988, in do_handshake
self._sslobj.do_handshake()
File "c:\Python35\lib\ssl.py", line 633, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed
(_ssl.c:645)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "", line 1, in 
File "c:\Python35\lib\urllib\request.py", line 163, in urlopen
return opener.open(url, data, timeout)
File "c:\Python35\lib\urllib\request.py", line 466, in open
response = self._open(req, data)
File "c:\Python35\lib\urllib\request.py", line 484, in _open
'_open', req)
File "c:\Python35\lib\urllib\request.py", line 444, in _call_chain
result = func(*args)
File "c:\Python35\lib\urllib\request.py", line 1297, in https_open
context=self._context, check_hostname=self._check_hostname)
File "c:\Python35\lib\urllib\request.py", line 1256, in do_open
raise URLError(err)
urllib.error.URLError: 

Anyone know how to deal with that? When using pip, I get same error, unless
I add "--trusted-host pypi.python.org":

C:\...>pip install nose
Collecting nose
Could not fetch URL https://pypi.python.org/simple/nose/: There was a
problem confirming the ssl certificate: [SSL: CERTIF
LED] certificate verify failed (_ssl.c:645) - skipping
Could not find a version that satisfies the requirement nose (from
versions: )
No matching distribution found for nose

C:\...>pip install nose --trusted-host pypi.python.org
Collecting nose
Downloading nose-1.3.7-py3-none-any.whl (154kB)
100% || 163kB 386kB/s
Installing collected packages: nose
Successfully installed nose-1.3.7


-- 
Oliver
-- 
Oliver
My StackOverflow contributions
My CodeProject articles
My Github projects
My SourceForget.net projects
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue28711] IDLE doesn't open

2016-12-11 Thread Oliver Schode

Oliver Schode added the comment:

This is a bug you'll run into whenever you set a key binding that is somehow 
ambiguous to IDLE and for some other reason than being already assigned (for in 
that case, IDLE will warn, but only then). Like when you set a binding, that 
would normally be interpreted by the editor for some input modification or so. 
I think this should be handled more gracefully or at least fail in a more 
informative way, esp. since beginners on Windows may not be that comfortable on 
the command line.

A "hard" workaround for the time being is to simply remove your config-keys.cfg 
file, thus resetting all bindings to their default. On Windows this is usually 
located in your .idlerc directory in C:\Users\YourName\. You might also edit 
this file by hand and just remove the offending binding, although that assumes 
you know which one it is, of course.

--
nosy: +Ritornell

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue28711>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



ANN: nose2pytest 1.0

2016-03-31 Thread oliver
Announcing a project hosted on GitHub called nose2pytest (
https://github.com/schollii/nose2pytest). This project helps migrate a test
suite that was written for Nose to work with pure pytest. It converts
nose.tools.assert_ functions into raw assert statements so you can better
(IMO) leverage pytest assertion introspection. It may even decrease test
suite dependencies by 1; after nose2test has been run on a test suite, it
is no longer needed.

The nose2pytest script has already successfully converted approximately
5000 assertions, so this is v1.0. However, there are many ways to harness
Nose functionality so I'm really curious to see if nose2test can be useful
to others.

I'm sure there is lots of room for improvement. Any feedback or
contributions would be much appreciated.

Regards,

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

Support the Python Software Foundation:
http://www.python.org/psf/donations/


[issue25668] Deadlock in logging caused by a possible race condition with "format"

2016-02-19 Thread Oliver Ruiz Dorantes

Oliver Ruiz Dorantes added the comment:

I am logging from a different thread than the thread which actually created the 
object. Though I am getting its reference in a very odd way

I can reproduce the following while is not a deadlock, I believe is related:

Traceback (most recent call last):
  File "/usr/lib/python2.7/logging/__init__.py", line 851, in emit
msg = self.format(record)
  File "/usr/lib/python2.7/logging/__init__.py", line 724, in format
return fmt.format(record)
  File "/usr/lib/python2.7/logging/__init__.py", line 464, in format
record.message = record.getMessage()
  File "/usr/lib/python2.7/logging/__init__.py", line 328, in getMessage
msg = msg % self.args
TypeError: not all arguments converted during string formatting

--
nosy: +Oliver Ruiz Dorantes

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25668>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



PythonCamp 2016 - Free (German) Knowledge Exchange

2016-01-11 Thread Oliver Frietsch
This is an announcement of a popular & free-to-participate, 
Python-focused un-conference taking place in Cologne, Germany. My 
apologies to all readers from other countries.


-

Liebe Python-Fans,

es ist wieder soweit: Am  * Freitag, den 15. Januar *  öffnen wir die 
Online-Anmeldung für Teilnehmer des PythonCamps 2016!


Die nunmehr siebte Ausgabe des PythonCamps wird erneut durch die Python 
User Group Köln sowie den Python Software Verband e.V. in den Räumen 
unseres Partners GFU Cyrus AG in Köln ausgerichtet.


* PythonCamp 2016: Sa-So, 02.04.2016 - 03.04.2016 *
*http://www.pythoncamp.de *

Unsere zweitägige Veranstaltung richtet sich an alle, die sich für die 
Programmiersprache Python und deren Einsatz begeistern - sei es im 
Bereich Web Development, Automatisierung, Scientific Computing oder 
einfach nur zum Spaß. Die Themen des PythonCamps sind so vielfältig wie 
die Einsatzmöglichkeiten von Python selbst, denn das Programm wird - wie 
bei einem BarCamp üblich - ausschließlich von unseren Teilnehmern selbst 
gestaltet.


Ihr habt einen Vortrag oder eine Demo im Angebot, möchtet eine 
Diskussionsrunde leiten oder mit Gleichgesinnten ein offenes 
Brainstorming abhalten? Alles ist möglich - bringt euren 
Session-Vorschlag einfach mit. Ihr seid noch keine "Vortrags-Veteranen"? 
Das macht nichts. In unserer familiären Atmosphäre haben schon viele 
Teilnehmer ihren ersten öffentlichen Vortrag gehalten - traut euch!


Dank unserer Sponsoren können wir euch diese "Un-Konferenz" *kostenlos* 
(Hinweis: Teilnahme nur nach Voranmeldung) anbieten und sorgen dabei 
tagsüber auch für euer leibliches Wohl. So treffen bei uns seit Jahren 
Berufstätige, Studenten und auch Schüler aus den verschiedensten 
Tätigkeitsfeldern, Branchen und Organisationen aufeinander und 
bereichern sich gegenseitig.


Meldet euch frühzeitig an - unsere Plätze sind begrenzt!

Euer PythonCamp Orga-Team
i...@pythoncamp.de

P.S.: Du kennst eine weitere Mailingliste, deren Leser unser PythonCamp 
ebenfalls interessieren könnte? Wir freuen uns über Anregungen!


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

   Support the Python Software Foundation:
   http://www.python.org/psf/donations/


[issue25446] smtplib.py AUTH LOGIN code messed up sending login and password data since 3.5

2015-10-20 Thread Oliver Merkel

New submission from Oliver Merkel:

class SMTP:
def auth_login(self, challenge=None):

The self.docmd should use cmd "AUTH" with parameter "LOGIN" + encoded login like

(code, resp) = self.docmd("AUTH", "LOGIN " +
encode_base64(self.user.encode('ascii'), eol=''))

with

def auth(self, mechanism, authobject, *, initial_response_ok=True):

that should not send a "AUTH" in self.docmd in case the mechanism is 'LOGIN' and

if initial_response is not None:

meaning

if mechanism == 'LOGIN':
(code, resp) = self.docmd(response)
else:
(code, resp) = self.docmd("AUTH", mechanism + " " + response)

---

Could someone kindly review, evtly come up with better suggestion?

In short:
$ diff /c/Python35/Lib/smtplib-old.py /c/Python35/Lib/smtplib.py
630c630,633
< (code, resp) = self.docmd("AUTH", mechanism + " " + response)
---
> if mechanism == 'LOGIN':
> (code, resp) = self.docmd(response)
> else:
> (code, resp) = self.docmd("AUTH", mechanism + " " + response)
660c663
< (code, resp) = self.docmd(
---
> (code, resp) = self.docmd("AUTH", "LOGIN " +

--
components: email
messages: 253225
nosy: barry, merkel, r.david.murray
priority: normal
severity: normal
status: open
title: smtplib.py AUTH LOGIN code messed up sending login and password data 
since 3.5
type: behavior
versions: Python 3.5

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25446>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25446] smtplib.py AUTH LOGIN code messed up sending login and password data since 3.5

2015-10-20 Thread Oliver Merkel

Oliver Merkel added the comment:

Sample session log output showing the error with smtp.set_debuglevel(1):

send: 'ehlo \r\n'
reply: b'250- Hello [myIP4address]\r\n'
reply: b'250-SIZE 53248000\r\n'
reply: b'250-PIPELINING\r\n'
reply: b'250-DSN\r\n'
reply: b'250-ENHANCEDSTATUSCODES\r\n'
reply: b'250-STARTTLS\r\n'
reply: b'250-AUTH GSSAPI NTLM\r\n'
reply: b'250-8BITMIME\r\n'
reply: b'250-BINARYMIME\r\n'
reply: b'250 CHUNKING\r\n'
reply: retcode (250); Msg: b' Hello [myIP4address]\
nSIZE 53248000\nPIPELINING\nDSN\nENHANCEDSTATUSCODES\nSTARTTLS\nAUTH GSSAPI NTLM
\n8BITMIME\nBINARYMIME\nCHUNKING'
send: 'STARTTLS\r\n'
reply: b'220 2.0.0 SMTP server ready\r\n'
reply: retcode (220); Msg: b'2.0.0 SMTP server ready'
send: 'ehlo [mymachinename]\r\n'
reply: b'250- Hello [myIP4address]\r\n'
reply: b'250-SIZE 53248000\r\n'
reply: b'250-PIPELINING\r\n'
reply: b'250-DSN\r\n'
reply: b'250-ENHANCEDSTATUSCODES\r\n'
reply: b'250-AUTH GSSAPI NTLM LOGIN\r\n'
reply: b'250-8BITMIME\r\n'
reply: b'250-BINARYMIME\r\n'
reply: b'250 CHUNKING\r\n'
reply: retcode (250); Msg: b' Hello [myIP4address]\
nSIZE 53248000\nPIPELINING\nDSN\nENHANCEDSTATUSCODES\nAUTH GSSAPI NTLM LOGIN\n8B
ITMIME\nBINARYMIME\nCHUNKING'
send: '==\r\n'
reply: b'500 5.3.3 Unrecognized command\r\n'
reply: retcode (500); Msg: b'5.3.3 Unrecognized command'
send: 'QUIT\r\n'
reply: b'221 2.0.0 Service closing transmission channel\r\n'
reply: retcode (221); Msg: b'2.0.0 Service closing transmission channel'
Traceback (most recent call last):
  File "sendtestmail.py", line 172, in 
announcement.sendMail(password)
  File "sendtestmail.py", line 97, in sendMail
smtp.login( self.getShortAddressList()[0], password )
  File "c:\Python35\lib\smtplib.py", line 730, in login
raise last_exception
  File "c:\Python35\lib\smtplib.py", line 721, in login
initial_response_ok=initial_response_ok)
  File "c:\Python35\lib\smtplib.py", line 627, in auth
initial_response = (authobject() if initial_response_ok else None)
  File "c:\Python35\lib\smtplib.py", line 664, in auth_login
raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (500, b'5.3.3 Unrecognized command')

due to missing AUTH LOGIN here as previously described...

--

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25446>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25446] smtplib.py AUTH LOGIN code messed up sending login and password data since 3.5

2015-10-20 Thread Oliver Merkel

Oliver Merkel added the comment:

Let us assume you want to establish a smtp session with AUTH LOGIN as the 
supported authentication type. Sample code to send mail: Typical preparation 
steps like

with SMTP( mailserver, 587 ) as smtp:
  # smtp.set_debuglevel(1)
  smtp.ehlo()
  smtp.starttls()
  smtp.ehlo()
  smtp.login( account, password )

If you try to login (last line in sample code above) at the smtp server then 
the smtp server will expect a command to be send like

AUTH LOGIN 

Now switching from sample code to our smtplib.py:

Since the "AUTH LOGIN" is missing in original Python35/Lib/smtplib.py in line...

660c663
< (code, resp) = self.docmd(
---
> (code, resp) = self.docmd("AUTH", "LOGIN " +

... the smtp server will answer that the library is sending an unknown command 
here. That is why I added... "AUTH", "LOGIN " + ...at this line.

Line 660 in class SMTP: def auth_login is called before it reaches line 630 in 
class SMTP: def auth

In case of authentication type AUTH LOGIN in line 630 you must not call with 
"AUTH", mechanism + " " +

So the following changes have to be applied at least for AUTH LOGIN mechanism

630c630,633
< (code, resp) = self.docmd("AUTH", mechanism + " " + response)
---
> if mechanism == 'LOGIN':
> (code, resp) = self.docmd(response)
> else:
> (code, resp) = self.docmd("AUTH", mechanism + " " + response)

The first change affecting line 660 described above will will imply that the 
you remove the AUTH mechanism in line 630. For mechanism LOGIN the base64 
encoded password will be needed to be sent in 660...

See possible fix in the diff above.

To ease understanding the fix I will apply a running version of my local 
Lib/smtplib.py (instead of just providing the diff lines). Feel free to 
directly use the file.

--
Added file: http://bugs.python.org/file40828/smtplib.py

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25446>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue25446] smtplib.py AUTH LOGIN code messed up sending login and password data since 3.5

2015-10-20 Thread Oliver Merkel

Oliver Merkel added the comment:

Change proposal attached as a unified diff / patch file.

--
keywords: +patch
Added file: http://bugs.python.org/file40829/smtplib-patch.issue25446.patch

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25446>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24386] Bug Tracker emails going to gmail spam

2015-06-04 Thread Graham Oliver

New submission from Graham Oliver:

I noticed that when I created an issue in this Bug Tracjer all of the 
associated emails were ending up in my gmail spam. '...in violation of Google's 
recommended email sender guidelines.' An explanatory link sends me to
https://support.google.com/mail/answer/81126?hl=en-GB#authentication
Cheers
g

--
components: email
messages: 244849
nosy: Graham.Oliver, barry, r.david.murray
priority: normal
severity: normal
status: open
title: Bug Tracker emails going to gmail spam
type: behavior
versions: Python 3.5

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24386
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24356] venv documentation incorrect / misleading

2015-06-01 Thread Graham Oliver

Graham Oliver added the comment:

See also
https://groups.google.com/d/msg/comp.lang.python/BUmyc_hzAsA/Nx5QgT1gzYEJ

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24356
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24356] venv documentation incorrect / misleading

2015-06-01 Thread Graham Oliver

New submission from Graham Oliver:

See my question here
https://groups.google.com/forum/#!topic/comp.lang.python/BUmyc_hzAsA
In particular Carl Meyer's response
https://groups.google.com/d/msg/comp.lang.python/BUmyc_hzAsA/-cT-N-g_LL4J

I am not sure what is possible with venv but I would suggest that the statement 
'allowing creation of environments with various Python versions' needs to be 
clarified and / or altered.

Thanks
Graham

--
assignee: docs@python
components: Documentation
messages: 244618
nosy: Graham.Oliver, docs@python
priority: normal
severity: normal
status: open
title: venv documentation incorrect / misleading
versions: Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24356
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue24356] venv documentation incorrect / misleading

2015-06-01 Thread Graham Oliver

Graham Oliver added the comment:

ok current version
Each virtual environment has its own Python binary (allowing creation of 
environments with various Python versions) and can have its own independent set 
of installed Python packages in its site directories.

Suggested Alternative
Each virtual environment has its own isolated Python binary (which matches the 
version used to create it) and can have its own independent set of installed 
Python packages in its site directories.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue24356
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9694] argparse required arguments displayed under optional arguments

2014-09-02 Thread Oliver Smith

Oliver Smith added the comment:

The term optional arguments is a poorly formed adjectival suffix of option. 
What it's trying to say is these are kwargs rather than these arguments are 
not compulsory.

I ran into this issue with 3.4 and was looking to file a simple change request:

In early DOS/Linux days we called these switches. I suggest we simply change 
the default wording from optional arguments to switches.

--
nosy: +Oliver.Smith
Added file: http://bugs.python.org/file36528/parrot.py

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9694
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3991] urllib.request.urlopen does not handle non-ASCII characters

2014-05-28 Thread Graham Oliver

Graham Oliver added the comment:

hello
I came across this bug when using 'ā' in a url
To get around the problem I used the 'URL encoded' version '%C4%81' instead of 
'ā'
See this page
http://www.charbase.com/0101-unicode-latin-small-letter-a-with-macron
I tried using the 'puny code' for 'ā' 'xn--yda' but that didn't work

--
nosy: +Graham.Oliver

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3991
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Python User Group Bonn: Wednesday, Feb. 27th, 19oc

2013-02-25 Thread Oliver Frietsch
[This is an announcement for a local user group in Bonn, Germany. 
Because of that, the rest of the text is in German. Sorry for that...]



-- ANKÜNDIGUNG -

*Python User Group Bonn*
  http://wiki.python-forum.de/pybonn

   *Mittwoch, 27. Februar 2013, 19 Uhr*

   Hochschulrechenzentrum der Universität Bonn
   Wegelerstraße 6, 53115 Bonn
  http://www.hrz.uni-bonn.de/ueber-uns/anreise



Die Python User Group Bonn ist eine neu gegründete Gruppe von 
Python-Anwendern und -Interessierten aus Bonn und dem Umland.


Wir würden uns freuen, im Rahmen unserer monatlichen Treffen möglichst 
viele Teilnehmer zu spannenden Vorträgen und ent-spanntem 
Erfahrungsaustausch versammeln zu können.


Ganz gleich ob Anfänger oder Profi, ob Web, Wissenschaft, Desktop, 
Embedded oder ein völlig anderes Einsatzgebiet, bei uns ist jeder 
Besucher und jedes Python-Thema willkommen!


Das Programm des Abends bestimmen die Teilnehmer durch ihre Beiträge 
dabei selbst. Für das Februar-Treffen sind bereits folgende Themen 
vorgesehen:


NumPy - Henning Dickten
Pandas - Maik Röder
IPython - Christian Geier

Die Länge der einzelnen Vorträge liegt bei jeweils etwa 10-15 Minuten; 
weitere Vorträge sind willkommen. Selbstverständlich besteht im 
Anschluss noch Gelegenheit zu Diskussion, Meinungs- und Erfahrungsaustausch.


Die Teilnahme an der gesamten Veranstaltung ist kostenfrei! Unser 
Treffpunkt liegt zentral in Bonn und ist gut mit öffentlichen 
Verkehrsmitteln oder dem PKW zu erreichen. Parkplätze stehen direkt 
neben dem Gebäude zur Verfügung.


Interesse? Dann bis Mittwoch!
Oliver Frietsch


Wiki:
http://wiki.python-forum.de/pybonn
Mailing-Liste:
http://lists.python-verband.org/mailman/listinfo/bonn
Verbands-Seite:
http://python-verband.org/community/bonn/python-user-group-bonn

--
Bonn mailing list
b...@lists.python-verband.org
http://lists.python-verband.org/mailman/listinfo/bonn
--
http://mail.python.org/mailman/listinfo/python-announce-list

   Support the Python Software Foundation:
   http://www.python.org/psf/donations/


Python User Group Bonn

2013-01-24 Thread Oliver Frietsch
[This is an announcement for a local user group in Bonn, Germany. 
Because of that, the rest of the text is in German. Sorry for that...]



-- ANKÜNDIGUNG -

*Python User Group Bonn*
  http://wiki.python-forum.de/pybonn

   *Mittwoch, 30. Januar 2013, 19 Uhr*

   Hochschulrechenzentrum der Universität Bonn
   Wegelerstraße 6, 53115 Bonn
 Konferenzraum in der 1. Etage (Raum 101)
  http://www.hrz.uni-bonn.de/ueber-uns/anreise



Die Python User Group Bonn ist eine neu gegründete Gruppe von 
Python-Anwendern und -Interessierten aus Bonn und dem Umland.


Wir würden uns freuen, im Rahmen unserer monatlichen Treffen möglichst 
viele Teilnehmer zu spannenden Vorträgen und ent-spanntem 
Erfahrungsaustausch versammeln zu können.


Ganz gleich ob Anfänger oder Profi, ob Web, Wissenschaft, Desktop, 
Embedded oder ein völlig anderes Einsatzgebiet, bei uns ist jeder 
Besucher und jedes Python-Thema willkommen!


Das Programm des Abends bestimmen die Teilnehmer durch ihre Beiträge 
dabei selbst. Für das Januar-Treffen sind bereits folgende Themen 
vorgesehen:


Event Logging mit Sentry - Andi Albrecht
Effiziente Entwicklung von Python Paketen - Maik Röder
Flask Python Web Framework - Jesaja Everling
Iteratoren und Generatoren in Python - Oliver Frietsch
Python Decorators - Jesaja Everling
List Comprehensions in Python - Timo Stollenwerk

Die Länge der einzelnen Vorträge liegt bei jeweils etwa 10-15 Minuten. 
Selbstverständlich besteht im Anschluss noch Gelegenheit zu Diskussion, 
Meinungs- und Erfahrungsaustausch.


Die Teilnahme an der gesamten Veranstaltung ist kostenfrei! Unser 
Treffpunkt liegt zentral in Bonn und ist gut mit öffentlichen 
Verkehrsmitteln oder dem PKW zu erreichen. Parkplätze stehen direkt 
neben dem Gebäude zur Verfügung.


Interesse? Dann bis Mittwoch!
Oliver Frietsch


Wiki:
http://wiki.python-forum.de/pybonn
Mailing-Liste:
http://lists.python-verband.org/mailman/listinfo/bonn
Verbands-Seite:
http://python-verband.org/community/bonn/python-user-group-bonn
--
http://mail.python.org/mailman/listinfo/python-announce-list

   Support the Python Software Foundation:
   http://www.python.org/psf/donations/


Re-raised exceptions in 2.7.3 -- stack trace missing

2012-05-14 Thread Oliver Beattie
Hi there

I'm tying to investigate a bit of a weird problem here. Basically, I've just 
upgraded Python (from 2.7.2 - 2.7.3) by way of an OS upgrade (Ubuntu), and now 
all the tracebacks I'm getting sent from my web app are looking like this:

http://dpaste.org/EgKJp/

As you can see, Django is correctly re-raising the exception, but the original 
stack trace is not there by way of sys.exc_info(). I've dug into the code a 
little and it seems fairly simple, exc_info is passed through logging.error 
from sys.exc_info() so I see no reason why this shouldn't work.

Bit perplexing, any idea what could cause this?

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


question on installing python 2.7.2 and tcl 8.5.10 on WinXP

2011-10-02 Thread Lynn Oliver
Hello,

I'm having problems building tcl/tk and python on Windows XP so that both are 
installed correctly.

1. ActivePython 2.7.2.5 works fine on my system but may be implicated in recent 
R6034 runtime errors from users.

2. Python.org 2.7.2 msi binaries install fine, but produce a tcl wasn't 
installed correctly runtime error from pyinstaller builds.  

3. I built Python.org 2.7.2 sources using MSVC++ 2008 Express with a lot of 
manual work for the subprocess wrappers. The buildbot tools, which should more 
or less automate that process, did not work for me.

4. I can build tcl/tk 8.5.10 using MinGW/Msys.

5. When I built the tkinter component, I placed the build of tcl/tk where it 
was expected by the build scripts, and VC++ reported that the build was 
successful.  However, if I start python.exe from the build directory, I can't 
import Tkinter (or tkinter).

I feel like I must be missing some basic understanding of how and where things 
are installed; having completed the builds I still don't know how to install 
the resulting files into the correct directories.  

Any suggestions?  

Thanks for your help,
Lynn-- 
http://mail.python.org/mailman/listinfo/python-list


TypeError: object.__init__() takes no parameters

2011-09-08 Thread Oliver
Hello together,

let me be honest with you, I am a poor programmer who can only do
Perl.
I tried to code a program in Perl, but found that another guy already
finished this job in Python.
Unlucky for me, this guy is now CEO of a company, not really
interested in supporting his old code.

If I want to run shapes.py I receive this error message:

=== error message ===

C:\Documents and Settings\mhg\Desktop\palcalcshapes.py
EE...
==
ERROR: test_fits (__main__.containerTests)
--
Traceback (most recent call last):
  File C:\Documents and Settings\mhg\Desktop\palcalc\shapes.py, line
265, in test_fits
cont = Container()
  File C:\Documents and Settings\mhg\Desktop\palcalc\shapes.py, line
90, in __init__
super(Container, self).__init__(xsize, ysize)
TypeError: object.__init__() takes no parameters

==
ERROR: test_place_bin (__main__.containerTests)
--
Traceback (most recent call last):
  File C:\Documents and Settings\mhg\Desktop\palcalc\shapes.py, line
257, in test_place_bin
cont = Container()
  File C:\Documents and Settings\mhg\Desktop\palcalc\shapes.py, line
90, in __init__
super(Container, self).__init__(xsize, ysize)
TypeError: object.__init__() takes no parameters

--
Ran 5 tests in 0.032s

FAILED (errors=2)

=== end of error message ===

Snippets of source code:

Line 264 - 268

def test_fits(self):
cont = Container()
cont.place_bin(0, 0, 210, 280)
self.assertEqual(False, cont.fits(Rectangle(0, 210, 280,
420)))
self.assertEqual(True, cont.fits(Rectangle(0, 280, 280, 490)))

Line 87 - 93

class Container(object):
Container to store  a number of non-overlapping rectangles.
def __init__(self, xsize=1200, ysize=800):
super(Container, self).__init__(xsize, ysize)
self.rect = Rectangle(0, 0, xsize, ysize)
self.boxes = []
self.last_placement_strategy = 0

Line 254 - 262

class containerTests(unittest.TestCase):
Tests for container objects.
def test_place_bin(self):
cont = Container()
cont.place_bin(0, 0, 40, 40)
self.failUnlessRaises(RuntimeError, cont.place_bin, 0, 0, 40,
40)
cont = Container()
cont.place_bin(0, 0, 210, 280)
self.failUnlessRaises(RuntimeError, cont.place_bin, 0, 210,
280, 420)

I think this is the main function:

if __name__ == '__main__':
unittest.main()

I do not know if I posted what you need to help me, it just would ease
my life a lot. If you need more information please let me know - if
you want you can even be unfriendly to me :)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Pipe in the return statement

2011-07-25 Thread Oliver Bestwalter
Hello Archard,

On 25.07.2011, at 16:16, Archard Lias wrote:

 On Jul 25, 2:03 pm, Ian Collins ian-n...@hotmail.com wrote:
 On 07/26/11 12:00 AM, Archard Lias wrote:
 
 Hi,
 
 Still I dont get how I am supposed to understand the pipe and its task/
 idea/influece on control flow, of:
 returnstatement  |statement
 ??
 
 It's simply a bitwise OR.
 
 --
 Ian Collins
 
 Yes, but how does it get determined, which one actually gets returned?

You do a Bitwise OR with numbers. Your statements are both returning numbers 
and those are combined with a bitwise OR. Combining b0001 with b0010 results in 
0011 for example, you can see this very often done in C Code to set and check 
flags. Here is a gentle introduction:

http://www.codeproject.com/KB/tips/Binary_Guide.aspxhttp://www.codeproject.com/KB/tips/Binary_Guide.aspx

Cheers
Oliver

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


[issue5863] bz2.BZ2File should accept other file-like objects. (issue4274045)

2011-04-03 Thread Oliver Deppert

Oliver Deppert oliver.depp...@stud.tu-darmstadt.de added the comment:

Hi,

thanks for the patch. Could you also publish a version for older python 2.x ?

regards,
Olli

--
nosy: +Kontr-Olli

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5863
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11332] Increase logging/__init__.py coverage to 97%

2011-02-27 Thread Oliver Drake

Oliver Drake obdrak...@gmail.com added the comment:

Thanks for the comments and prompt response :) I think I misunderstood the 
nature and level of these unit tests. I will fix the specific issues you 
mentioned, and either cut or modify the less useful/too low level tests (e.g. 
disable). In general I will change my approach to be more high level. I will 
steer away from testing the implementation line by line, but I believe there 
should be unit tests that enforce the API that is published to the user - i.e. 
one unit test for every class, method and function, testing inputs, outputs, 
exception handling and general behavior. So if a developer changes the API or 
the general behavior of a function he/she should have to change the 
documentation and the appropriate unit test - or do we want to avoid this type 
of testing completely?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11332
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11332] Increase logging/__init__.py coverage to 97%

2011-02-26 Thread Oliver Drake

New submission from Oliver Drake obdrak...@gmail.com:

Purely a modification to test_logging.py with the focus being to increase 
coverage. coverage.py now measures 97% (when running test_logging.py by 
itself). I'm not sure if I've followed py-dev unit test conventions exactly, 
I've created quite a few new test case classes, going by the model of having 
one unittest test case class for each class defined in the module under test. 
Comments welcome :)

--
components: Tests
files: test_logging.diff
keywords: patch
messages: 129530
nosy: drakeol
priority: normal
severity: normal
status: open
title: Increase logging/__init__.py coverage to 97%
versions: Python 3.2
Added file: http://bugs.python.org/file20908/test_logging.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11332
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Embedded python issue with gtk

2010-11-10 Thread Oliver Marks
I have already emailed about this issue, but have still not got any
where.

I have reduced the plugin down to its bare minimum it simple loads the
the python interpreter and imports gtk library.

If i do this outside the embedded python it imports and i can use the
gtk library, so why does it not work when embedded i am on ubuntu 10.10
64bit if its a specific issue on this platform.

the code is below or you can get the code with the build system from the
link below, obviously to see the error you need to load the plugin into
geany.

I am guessing this is a linking issue just hoping someone can point me
in the right direction.

http://ubuntuone.com/p/OhA/


#include Python.h  /* For Python itself. This MUST come first.
*/
#include geany.h  /* for the GeanyApp data type */
#include geanyplugin.h  /* for the GeanyApp data type */
#include plugindata.h /* this defines the plugin API */

#define PLUGIN_NAME _(Geany Python Test)

PLUGIN_VERSION_CHECK(GEANY_API_VERSION)

/* All plugins must set name, description, version and author. */
PLUGIN_SET_INFO(PLUGIN_NAME, _(Test Python plugin.), _(VERSION),
_(Test Author))


/* initialise the plugin */
void plugin_init(GeanyData *data){
printf(Loading the test Python module.\n);
Py_Initialize();/* Start the Python interpreter. */
PyRun_SimpleString(import gtk);
}

/* Cleanup the plugin when required */
void plugin_cleanup(void){
Py_Finalize();
}


This is the error i get on loading of the plugin.

Traceback (most recent call last):
  File string, line 1, in module
  File /usr/lib/pymodules/python2.6/gtk-2.0/gtk/__init__.py, line 30,
in module
import gobject as _gobject
  File /usr/lib/pymodules/python2.6/gtk-2.0/gobject/__init__.py, line
26, in module
from glib import spawn_async, idle_add, timeout_add,
timeout_add_seconds, \
  File /usr/lib/pymodules/python2.6/gtk-2.0/glib/__init__.py, line 22,
in module
from glib._glib import *
ImportError: /usr/lib/libpyglib-2.0-python2.6.so.0: undefined symbol:
PyExc_ImportError


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


embedding python ImportError: libpyglib PyExc_ImportError

2010-10-28 Thread Oliver Marks

Hi i am a new member on this list and thought if some people may be able
to enlighten me to the error below ?

I am running 64 bit ubuntu 10.10 and python 2.6 in case there are know
issues with this
setup, basically i am embedding python inside a c application i managed
to get this to work i can call functions from the original c program and
the scripts run until i import gtk in the python script this causes the
error below.

I am using the waf build system to build the c program, my knowledge of
c is limited i am more a python programmer which is why i am attempting
the embed python so i can write my plugins in python.

I get the feeling the error is todo with linking but i dont get why i
can import gtk normally in python but not when its embeded ?

Any help or pointers would be appreciated, that might help me get this
solved or better understand what is wrong.

Traceback (most recent call last):
  File /usr/local/share/geany/plugins/gpykickstart.py, line 4, in
module
import glib
  File /usr/lib/pymodules/python2.6/gtk-2.0/glib/__init__.py, line 22,
in module
from glib._glib import *
ImportError: /usr/lib/libpyglib-2.0-python2.6.so.0: undefined symbol:
PyExc_ImportError
Failed to load the gpykickstart module from the
/usr/local/share/geany/plugins directory.


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


[issue1625] bz2.BZ2File doesn't support multiple streams

2010-10-17 Thread Oliver Deppert

Oliver Deppert oliver.depp...@stud.tu-darmstadt.de added the comment:

Thanks for the update

Like I mentioned before in my previous comment, I'm still searching for a 
solution/patch for python 2.x able to handle multiple streams of bz2. 

Does anybody know a work-around or have a solution porting the p3k-patch to the 
good old python 2.x?!

At the moment I try to use this patch with py3k and it seems to work. But I 
need this multistream option for pythone 2.x because the most of the time I 
deal with matplotliband matplotlib at the moment isn't able to deal with 
py3kso, I would be very happy for any suggestion running multiple-streams 
with python 2.x ! !

Thank you very much, and best regards
Kontr-Olli

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1625
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1625] bz2.BZ2File doesn't support multiple streams

2010-08-29 Thread Oliver Deppert

Oliver Deppert oliver.depp...@stud.tu-darmstadt.de added the comment:

Dear all,

first of all, thank you for the patch making multiple file-streams in bz2 
available in python. Yesterday, I've tried to adapt the recent patch for python 
3k to the actual python 2.7. Most of the hunks could be easy adapted by editing 
just one ore two things concerning the different file-layout between p3k and 
python 2.7.

Unfortunatelly it wasn't possible for me to completly downgrade this patch to 
python 2.7. Especially the last hunk in the patch and also the hunks which are 
related to self-rawfp couldn't be adapted succesfully by me.

Could anybody assist me to make this patch available for python 2.7 or does a 
patch for this python version already exist?

If you like, I can upload my recent changes in this patch for further 
investigation.

Thank you!

best regards,
Oliver Deppert

--
nosy: +Kontr-Olli

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1625
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



requirements in writing an email/rss/usenet client?

2010-08-08 Thread George Oliver
hi,

I'd like to know what to consider when writing an email/rss/usenet
client. Apologies for such a broad question, but I've never attempted
a project of this scope and I'm currently feeling out the
requirements.

My target is something like a gui-based mutt (I use a Windows OS btw),
with influences from programs like Alpine (http://www.washington.edu/
alpine/) and Sup (http://sup.rubyforge.org/).

I currently use Thunderbird + Muttator, which is a nice setup; but, it
has some clunky parts, and I thought it might be simpler in the end to
start fresh than try to engage with what seems to be the massive-ness
of Thunderbird (of course, I may be disabused of this notion at some
point ;) ).


So far I've looked at the email and related modules in the standard
lib, found some related links from the list [1], and read a little
about the relevant protocols involved.

I'd appreciate hearing about any other examples, references, or
experiences of people who've written similar programs or related
libraries.


thanks, George


[1] Including references to:

* http://sourceforge.net/projects/usablemail/
* http://proquest.safaribooksonline.com/0596000855/python2-CHP-11-SECT-4
* http://wiki.laptop.org/go/Email
* the pyne client
* http://chandler.osafoundation.org/



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


[issue1079] decode_header does not follow RFC 2047

2010-04-10 Thread Oliver Martin

Oliver Martin oli...@volatilevoid.net added the comment:

I got bitten by this too. In addition to not decoding encoded words without 
whitespace after them, it throws an exception if there is a valid encoded word 
later in the string and the first encoded word is followed by something that 
isn't a hex number:

 decode_header('aaa=?iso-8859-1?q?bbb?=xxx asdf =?iso-8859-1?q?jkl?=')
Traceback (most recent call last):
  File stdin, line 1, in module
  File /usr/lib/python2.5/email/header.py, line 93, in decode_header
dec = email.quoprimime.header_decode(encoded)
  File /usr/lib/python2.5/email/quoprimime.py, line 336, in header_decode
return re.sub(r'=\w{2}', _unquote_match, s)
  File /usr/lib/python2.5/re.py, line 150, in sub
return _compile(pattern, 0).sub(repl, string, count)
  File /usr/lib/python2.5/email/quoprimime.py, line 324, in _unquote_match
return unquote(s)
  File /usr/lib/python2.5/email/quoprimime.py, line 106, in unquote
return chr(int(s[1:3], 16))
ValueError: invalid literal for int() with base 16: 'xx'

I think it should join the encoded words with the surrounding text if there's 
no whitespace in between. That seems to be consistent with what the 
non-RFC-compliant MUAs out there mean when they send such things.

Reverting the change from Issue 1582282 doesn't seem to be a good idea, since 
it was introduced in response to problems with mailman (see 
https://bugs.launchpad.net/mailman/+bug/266370). Instead of leaving 
Sm=?ISO-8859-1?B?9g==?=rg=?ISO-8859-1?B?5Q==?=sbord as it is, my patch 
converts it to [('Sm\xf6rg\xe5sbord', 'iso-8859-1')]. This shouldn't 
reintroduce the problem mailman was having while fixing ours.

--
nosy: +leromarinvit
Added file: http://bugs.python.org/file16857/rfc2047_embed.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1079
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



string.Template question

2010-04-05 Thread Wells Oliver
Can you use dicts with string.Template?

e.g. a structure like:

game = {
'home': {'team': row['home_team_full'], 'score': 
row['home_score'],
'record': '0-0', 'pitcher': {
'id': home_pitcher.attrib['id'], 'name':
home_pitcher.attrib['last_name'], 'wins': home_pitcher.attrib['wins'],
'losses': home_pitcher.attrib['losses']
}, 'win': home_win}
}

Then, in the template, 'game' is passed, but I want to access like
$home.pitcher.id

This doesn't seem to work, though. Is it possible? Or must everything
in the dict passed to string.Template be one-level deep string
variables?
-- 
http://mail.python.org/mailman/listinfo/python-list


[issue8064] Large regex handling very slow on Linux

2010-03-04 Thread Oliver Sturm

New submission from Oliver Sturm oli...@sturmnet.org:

The code in regextest.py (attached) uses a large regex to analyze a piece of 
text. I have tried this test program on two Macs, using the standard Python 
distributions.

On a MacBook, 2.4 GHz dual core, Snow Leopard with Python 2.6.1, it takes 0.08 
seconds
On a MacPro, 2.something GHz 8 core, Leopard with Python 2.5.1, it takes 0.09 
seconds

Now I've also tried it on several Linux machines, all of them running Ubuntu. 
They are all extremely slow. The machine I've been testing with now is a 2.0 
GHz dual core machine with Python 2.5.2. A test run of the program takes 97.5 
(that's not a typo) seconds on this machine, 1200 times as long as on the Macs.

--
components: Regular Expressions
files: regextest.py
messages: 100434
nosy: michael.foord, olivers
severity: normal
status: open
title: Large regex handling very slow on Linux
type: resource usage
versions: Python 2.5
Added file: http://bugs.python.org/file16440/regextest.py

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue8064
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



ANN: A forum and project gallery for Python game development

2010-02-25 Thread George Oliver
Pyed Pypers is a community where you can upload your game project,
comment on other projects, build teams, ask for technical help, and
discuss everything about game development with Python.

If this catches your interest, check it out at http://www.pyedpypers.org.



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

Support the Python Software Foundation:
http://www.python.org/psf/donations/


[issue7918] distutils always ignores compile errors

2010-02-12 Thread Oliver Jeeves

New submission from Oliver Jeeves ojee...@gmail.com:

When trying to build a python package for distribution, compile errors are 
always ignored. The setup function will return successfully even if it was 
unable to compile some modules due to, for example, indentation errors.

The specific situation I'm trying to deal with, is a script that builds a large 
number of eggs, and trying to detect if something went wrong.

I see that this has been raised as a bug for setuptools:

http://bugs.python.org/setuptools/issue61

But it's not considered an issue because it's how distutils works.

distutils.util.byte_compile calls py_compile.compile, but does not pass a 
doraise argument to it.

The only suggestion for how to get tools that use distutils.util.byte_compile 
(like setuptools.setup and distutils.core.setup) to exit on an error is to 
monkey patch py_compile.compile to change its default doraise argument to True. 
That suggestion came from here:

http://stackoverflow.com/questions/2230843/how-can-i-detect-errors-programatically-when-building-an-egg-with-setuptools

supressing compile errors when making a distribution seems like a bug to me, 
but just having the option to easily change this behaviour would be great.

--
assignee: tarek
components: Distutils
messages: 99273
nosy: Oliver.Jeeves, tarek
severity: normal
status: open
title: distutils always ignores compile errors
type: feature request
versions: Python 2.6

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue7918
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



looking for Python live code reloading IDEs

2010-01-22 Thread George Oliver
hi, I'm wondering if there are any Python programming environments
that enable live code reloading, for example something like the Scheme-
based impromptu (but also meant for any kind of Python program, not
just audio/visual generation).

Currently I do this directly in my editor (for game development), but
I'm curious if there are other options.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Newsgroup for beginners

2009-11-16 Thread George Oliver
On Nov 16, 8:35 am, Terry Reedy tjre...@udel.edu wrote:
 mrholtsr wrote:
  Is there a Python newsgroup for those who are strictly beginners at
  programming and python?

 gmane.comp.python.tutor, which I believe mirrors the tutor-list

There also is a beginner's forum at python-forum.org:

http://www.python-forum.org/pythonforum/viewforum.php?f=3
-- 
http://mail.python.org/mailman/listinfo/python-list


Ordering of dict keys values

2009-08-03 Thread Wells Oliver
I understand that the keys in a dictionary are ordered not randomly but
something practically close to it, but if I create a SQL query like so:

query = 'INSERT INTO Batting (%s) VALUES(%s)' % (','.join(stats.keys()),
','.join(stats.values()))

Can I at least rely on the value being in the same index as its
corresponding key?

-- 
Wells Oliver
we...@submute.net
-- 
http://mail.python.org/mailman/listinfo/python-list


RPY2 examples?

2009-07-22 Thread Wells Oliver
I am trying to find examples using RPY2 to render R graphs to PNG/PDF/etc.
The only things I can find use rpy 1.x. Any references? Thanks!

-- 
Wells Oliver
we...@submute.net
-- 
http://mail.python.org/mailman/listinfo/python-list


Question regarding style/design..

2009-07-17 Thread Wells Oliver
Sometimes I see relatively small application, generally task scripts,
written as essentially a list of statements. Other times, I see them neatly
divided into functions and then the if __name__ == '__main__': convention.
Is there a preference? Is there an... application scope such that the
preference shifts from the former to the latter? I understand the use of the
__name__ == 'main' convention for building unit tests, but I'm mixed on
using it in scripts/small applications.
Thanks for any thoughts!

-- 
Wells Oliver
we...@submute.net
-- 
http://mail.python.org/mailman/listinfo/python-list


interactive fiction in Python?

2009-07-15 Thread George Oliver
hi, I'm just curious who might be working on interactive fiction
modules in the style of Inform or TADS for Python. I've seen a few
threads on this list [1] (among many that mention IF tangentially),
and there are old projects like PUB and PAWS. There are some newer
potential projects such as Curveship as well. In any case I'd like to
see what's out there.


thanks, George


[1]:

http://bit.ly/Python_Text_Adventure_Authoring_System

http://bit.ly/simple_interactive_fiction_engine

http://bit.ly/adventure_engines_in_Python
-- 
http://mail.python.org/mailman/listinfo/python-list


MySQLdb and ordering of column names in list returned by keys() w/ a DictCursor

2009-07-02 Thread Wells Oliver
Is there some kind of mysterious logic to how the the columns are ordered
when executing the following:

sql = SELECT player_id, SUM(K) AS K, SUM(IP) AS IP, SUM(ER) AS ER, SUM(HR)
AS HR, SUM(H) AS H, SUM(BB) AS BB, Teams.league FROM Pitching INNER JOIN
Teams ON Pitching.team = Teams.team_id WHERE Date BETWEEN '%s' AND '%s'
GROUP BY player_id % (start, date)
cursor.execute(sql)

for row in cursor.fetchall():
print row.keys()

What I get is:

['league', 'BB', 'HR', 'IP', 'K', 'H', 'player_id', 'ER']

Neither alphabetical nor the order in which they were specified in the query
nor... any seeming order I can suss out. Any ideas? Thanks!

(cursor being a MySQLdb.cursors.DictCursor object.)

-- 
Wells Oliver
we...@submute.net
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: MySQLdb and ordering of column names in list returned by keys() w/ a DictCursor

2009-07-02 Thread Wells Oliver
Will this order at least be the same for that same query every time the
script is executed?

On Thu, Jul 2, 2009 at 10:48 AM, Tim Chase python.l...@tim.thechases.comwrote:

 sql = SELECT player_id, SUM(K) AS K, SUM(IP) AS IP, SUM(ER) AS ER, SUM(HR)
 AS HR, SUM(H) AS H, SUM(BB) AS BB, Teams.league FROM Pitching INNER JOIN
 Teams ON Pitching.team = Teams.team_id WHERE Date BETWEEN '%s' AND '%s'
 GROUP BY player_id % (start, date)
 cursor.execute(sql)

 for row in cursor.fetchall():
print row.keys()

 What I get is:

 ['league', 'BB', 'HR', 'IP', 'K', 'H', 'player_id', 'ER']

 Neither alphabetical nor the order in which they were specified in the
 query
 nor... any seeming order I can suss out. Any ideas? Thanks!

 (cursor being a MySQLdb.cursors.DictCursor object.)


 My guess is you're experiencing the fact that dicts are unordered by nature
 which allows it to return in any order it likes (usually per the internal
 representation/storage).

 -tkc






-- 
Wells Oliver
we...@submute.net
-- 
http://mail.python.org/mailman/listinfo/python-list


n00b confusion re: local variable referenced before assignment error

2009-06-19 Thread Wells Oliver
Writing a class which essentially spiders a site and saves the files
locally. On a URLError exception, it sleeps for a second and tries again (on
404 it just moves on). The relevant bit of code, including the offending
method:

class Handler(threading.Thread):
def __init__(self, url):
threading.Thread.__init__(self)
self.url = url

def save(self, uri, location):
try:
handler = urllib2.urlopen(uri)
except urllib2.HTTPError, e:
if e.code == 404:
return
else:
print retrying %s (HTTPError) % uri
time.sleep(1)
self.save(uri, location)
except urllib2.URLError, e:
print retrying %s % uri
time.sleep(1)
self.save(uri, location)

if not os.path.exists(os.path.dirname(location)):
os.makedirs(os.path.dirname(location))

file = open(location, w)
file.write(handler.read())
file.close()

...

But what I am seeing is that after a retry (on catching a URLError
exception), I see bunches of UnboundLocalError: local variable 'handler'
referenced before assignment errors on line 38, which is the
file.write(handler.read()) line..

What gives?

-- 
Wells Oliver
we...@submute.net
-- 
http://mail.python.org/mailman/listinfo/python-list


A question on scope...

2009-06-18 Thread Wells Oliver
In writing out python classes, it seems the 'self' is optional, meaning that
inside a class method, self.foo = bar has the same effect as foo = bar.
Is this right? If so, it seems a little odd- what's the rationale?

Or am I mistaken?

-- 
Wells Oliver
we...@submute.net
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: call function of class instance with no assigned name?

2009-05-06 Thread George Oliver
On May 6, 3:07 pm, Carl Banks pavlovevide...@gmail.com wrote:

 I'm going to guess that you want the keyboardHandler to call method of
 commandHandler.  There's no reason for commandHandler to be a handler
 at all then: keyboardHandler is already handling it.


Thanks Carl, you've got it right and your following example is what I
ended up using, it's good to know it's a workable solution.
--
http://mail.python.org/mailman/listinfo/python-list


call function of class instance with no assigned name?

2009-05-05 Thread George Oliver
hi, I'm a Python beginner with a basic question. I'm writing a game
where I have keyboard input handling defined in one class, and command
execution defined in another class. The keyboard handler class
contains a dictionary that maps a key to a command string (like 'h':
'left') and the command handler class contains functions that do the
commands (like def do_right(self):),

I create instances of these classes in a list attached to a third,
'brain' class. What I'd like to have happen is when the player presses
a key, the command string is passed to the command handler, which runs
the function. However I can't figure out a good way to make this
happen.

I've tried a dictionary mapping command strings to functions in the
command handler class, but those dictionary values are evaluated just
once when the class is instantiated. I can create a dictionary in a
separate function in the command handler (like a do_command function)
but creating what could be a big dictionary for each input seems kind
of silly (unless I'm misunderstanding something there).

What would be a good way to make this happen, or is there a different
kind of architecture I should be thinking of?
--
http://mail.python.org/mailman/listinfo/python-list


Re: call function of class instance with no assigned name?

2009-05-05 Thread George Oliver
On May 5, 9:01 am, Chris Rebert c...@rebertia.com wrote:
 On Tue, May 5, 2009 at 8:52 AM, George Oliver georgeolive...@gmail.com 
 wrote:

  I create instances of these classes in a list attached to a third,
  'brain' class.

 You could exploit Python's dynamism by using the getattr() function:


Thanks for the responses -- I should have mentioned that I looked at
the getattr() function, but as I instantiate the key handler and
command handler classes in a list (like handlers = [command_handler(),
keyboard_handler()], I'm unsure how to reference that class instance
in the getattr in a straightforward way (short of keeping track of
each instance's position in the handlers list). Is there a typical way
of doing that?

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


Re: call function of class instance with no assigned name?

2009-05-05 Thread George Oliver
On May 5, 11:59 am, Dave Angel da...@ieee.org wrote:

 1) forget about getattr() unless you have hundreds of methods in your
 map.  The real question is why you need two maps. What good is the
 command string doing you?   Why not just map the keyvalues directly
 into function objects?


Thanks for the reply Dave. I understand your example and it's what I
originally used. Here is more detail on what I'm doing now, I hope
this will explain my question better.

In the game I'm writing the player, monsters, items and so on are
instances of class Thing, like:

class Thing(object):
def __init__(self, x, y, name):
self.x, self.y = x, y
self.name = name
self.brain = None

Some Things have an instance of class Brain attached. The Brain
instance has a list of handlers, like:

class Brain(object):
def __init__(self):
self.handlers = []

A handler class defines some functionality for the Brain. Each Brain
has an update method like this:

def update(self, arguments):
for handler in self.handlers:
handler.update(arguments)

So on each pass through the main game loop, it calls the update method
of all the brains in the game, which run their handler update methods
to change the state of the game.

A handler would be something like a key input handler. The key input
handler is defined separately from the command handler in the case I
want to use a different method of input, for example a mouse or
joystick.

In the dictionary of key inputs I could map each input directly to a
function. However there is no instance name I can call the function
on, as I create a thing, add a brain, and add handlers to the brain
like this:

player = Thing(26, 16, 'player')
player.brain = Brain()
player.brain.add_handlers(
commandHandler(player.brain, player),
keyboardHandler(player.brain),
fovHandler(player.brain))


So what I'm wondering is how to reference the instance in each brain's
list of handlers when I want to map something like a key input to a
command, or what a better way might be to structure the code.






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


Re: call function of class instance with no assigned name?

2009-05-05 Thread George Oliver
Thanks for the suggestions so far. I've taken the advice to keep
things simple so currently I'm just creating one instance of the
commandHandler and assigning it a name with command = commandHandler
(). This makes it easy to call it from any of the other handlers, and
I think this will work for what I want the game to do.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Python Query: Related to locking a resource in a multithreaded environment

2008-08-19 Thread Nils Oliver Kröger
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi,

I don't think the global interpreter lock is what you need ... read here
for reference:

http://docs.python.org/api/threads.html

My approach what be to write one class for reading and writing to the
configuration and make that class thread-safe using the RLock.

Then you create one and only one instance of this class and let all your
threads use (not import) that one instance.

You could achieve that one and only one either by having a main
program which creates the instance and pass the reference to each thread
via its __init__ or you implement the Configuration class as a singleton
like this:


class Singleton(object):

A simple example implementing the singleton design pattern in
python

#we need two class attributes (which translate to static
attributes in java)
__lock = Lock() #a lock for thread safety
__instance = None #and to remember the one instance

#first of all: make pythons usual way of creating objects   
# unusable because we cannot just hide them as one would in java
# or C++
def __new__(cls, *args, **kwargs):
pass

def __init__(self):
pass

@classmethod
def getInstance(cls, *args, **kwargs):

The famous gatInstance method which resturns the one instance of
our
class.

params:
cls - reference to the class
*args - the tuple of arguments paassed by position
**kwargs - the dictionary of arguments passed by keyword

#enter critical section
cls.__lock.acquire()
try:
if cls.__instance is None:
#use the superclasses __new__ for creation
cls.__instance = object.__new__(cls, *args, 
**kwargs)

#place initialisation code (everything which
#would usually
happen in __init__) here
cls.__instance.SomeInt = 1
finally:
#leave critical section
cls.__lock.release()

return cls.__instance


Add your methods for accessing as instance methods to this class and get
the same instance of this class in each thread by calling
Singleton.getInstance().

Hope that helps

Regards

Nils

tarun schrieb:
 I think I need something called global interpreter lock which is
 accessible to all the threads. But I am not sure how to implement this.
 
  
 On Tue, Aug 19, 2008 at 11:28 AM, tarun [EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED] wrote:
 
 Hello All,
  
 I've a configuration.ini file. This particular can be accessed by
 several threads of my application. Each thread can read/write
 configuration parameters from/to the configuration.ini file. I am
 using threading (Rlock) to lock the resource (configuration.ini
 file) while accessing it from any thread. I use the file available
 at http://www.voidspace.org.uk/python/configobj.html for read/write.
  
 I did the following in one of my files:
  
 import threading
 class Synchronization:
   def __init__(self):
 self.mutex = threading.RLock()
  
 Now this I can create instances of the class Synchronization and use
 acquire/release to work on the shared resource. But every thread
 would need to import this class and hence each thread would create a
 separate instance of the class. This means several lock variables.
 But I think we need a global lock flag that is accessible across all
 the threads.
  
 How do i do this?
  
 Please let me know ASAP.
  
 Thanks In Advance,
 Tarun
 
 
 
 
 
 --
 http://mail.python.org/mailman/listinfo/python-list
-BEGIN PGP SIGNATURE-

iD8DBQFIqxfCzvGJy8WEGTcRApe+AJ9MNqWI9FOsJIKuTKxy8ZNSGYTy2gCdHtGc
clDPMMAPRoIxsBvVm4ygi6U=
=vIPW
-END PGP SIGNATURE-
begin:vcard
fn;quoted-printable:Nils Oliver Kr=C3=B6ger
n;quoted-printable:Kr=C3=B6ger;Nils Oliver
email;internet:[EMAIL PROTECTED]
version:2.1
end:vcard

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

sending input to an embedded application

2008-07-12 Thread George Oliver
hi, I'm a novice programmer trying to better define a hobby project
I'm thinking of.

What I would like to do is take a program and embed it or put it
within a Python-run GUI, using the GUI just to capture and send input
to the application, and display the ouput.

Specifically I want to use a Python module such as wxPython, pygame or
pyglet to build the UI, capture key presses, and then send a string to
the program, an interactive fiction interpreter; the reason for this
is that the interpreter on its own doesn't have the capability to
recognize certain key presses on the keyboard. I thought that writing
a middle layer rather than a brand new interpreter would be easier for
someone of my skill level.

The interpreter would send its output to the Python GUI. The GUI then
would be as light/translucent as possible, just accepting input,
sending it to the interpreter, and displaying the output as if you
were just running the interpreter by itself.

As I don't really know the issues involved, I'm hoping someone can
point me in the right direction. Do people 'frame' programs with
something like wxPython or pygame and use the frame to capture and
pass along input, and receive and display the output?


thanks, George
--
http://mail.python.org/mailman/listinfo/python-list


2D online multiplayer framework?

2008-06-28 Thread George Oliver
I'm looking for a framework to support a 2D online real-time
multiplayer game (rugby league football with a lo-fi pixel look). The
GameProgramming page at the Python wiki had some suggestions but so
far nothing looks that promising, does anyone have some
recommendations?

It would be ideal to play this through a web browser but I don't know
if that's practical.

This aspect of programming is pretty new to me so I'm not sure if I
should start with something general like Twisted or if there's a
different path I should take.


thanks, George
--
http://mail.python.org/mailman/listinfo/python-list


Re: 2D online multiplayer framework?

2008-06-28 Thread George Oliver
On Jun 28, 9:04 am, Gary Herron [EMAIL PROTECTED] wrote:

 Pyglet is my favorite:  http://www.pyglet.org/

 Twisted might be fine for the online multiplayer parts, but really if
 you want a 2D/3D real-time game, start with a game framework.

 Gary Herron

Thanks Cédric and Gary for the suggestions, I'm familiar with all of
those. So a good workflow for a graphical online game is to make the
game first and just plan for the incoming connections without knowing
how they will be done exactly? My only experience with networked games
is muds, where usually you do the opposite -- sockets first.

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


Re: Learning Python in a group

2008-06-22 Thread George Oliver
On Jun 22, 3:43 am, Jonathan Roberts [EMAIL PROTECTED]
wrote:
 Hi all,

 I'm looking to learn Python (as my first programming language) and I'm
 pretty sure I'd be more successful doing this with a group of other
 people.

hi Jon, I'm in the same situation as you and think a co-op method of
learning could be effective and fun. I found the Tutor list that David
mentioned a little while ago but also have been looking for a group
(without success so far). So count me in!


best, George

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


Re: Cant run application as ./myapp.py

2008-03-03 Thread Nils Oliver Kröger
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi Robert,

I have to guesses:

a) The user as which you are trying to run the script is missing the
execute right - fix by chmod u+x MyApplication.px

b) You did not specify the interpreter - the first line of your script
should look something like #!/usr/bin/python

If none of this is the problem please post the error message you
(hopefully) get.

hth

Nils

Robert Rawlins schrieb:
 Hello Guys,
 
  
 
 I’ve got an application here which for some reason won’t start using the
 following syntax from the command line:
 
  
 
 Cd /mydirectory
 
 ./MyApplication.py
 
  
 
 I have to run this as a fully qualified python launch such as:
 
  
 
 Cd /mydirectory
 
 python MyApplication.py
 
  
 
 This is a little bit confusing to me as I have other applications which
 run just fine using the ./somthing.py syntax. Is there any reason why
 this doesn’t work?
 
  
 
 Cheers,
 
  
 
 Robert
 
-BEGIN PGP SIGNATURE-

iD8DBQFHzALBzvGJy8WEGTcRAtE8AJ4jGFTjZ8G8ayZM2AUcLcArnF5d1QCdH0gj
kCdp0414HwPaIMIDv/SSTZA=
=tF3K
-END PGP SIGNATURE-
begin:vcard
fn;quoted-printable:Nils Oliver Kr=C3=B6ger
n;quoted-printable:Kr=C3=B6ger;Nils Oliver
email;internet:[EMAIL PROTECTED]
version:2.1
end:vcard

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

Re: Exception or not

2008-03-03 Thread Nils Oliver Kröger
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hello,

I don't think it is a good pattern because you are kind of mixing
exceptions with return codes which makes the code a lot less readable
later on.

I personally would strongly opt for return codes in this case as one
would intuitively expect a function named validateThisAndThat to return
the result of a validation. This might me a simple true/false, a numeric
code with 0=OK, 1=password not correct, 2=user does not exist or a
string, whatever you need.

In my opinion, such a function should raise an exception if it is unable
to fullfill its task. For example lost connection to user database or
things like that. A function should never propagate an expected result
as an exception.

Greetings Nils

Monica Leko schrieb:
| Suppose you have some HTML forms which you would like to validate.
| Every field can have different errors.  For example, this are the
| forms:
|
| username
| password
| etc
|
| And you want to validate them with some class.  Is this good pattern:
|
| class Foo(object):
| def validateUsername(username):
|   if username isn't correct:
| raise ValidationError()
| def validatePassword(password):
|   if password isn't correct:
| raise ValidationError()
|
| code:
| try:
|   usernameError = validateUsername()
| except ValidationError:
|   usernameError = error from exception
| try:
|   passwordError = validatePassword()
| except ValidationError:
|   passwordError = error from exception
|
| So, if there wasn't any errors, usernameError and passwordError both
| contains None, and there was error, both contains some string?  Should
| I use exception or just return None or some string without
| exception?

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHzCGhzvGJy8WEGTcRAvbGAJoDjn39xCmiOLmkc//0RTfeVXJFTACePRIG
uYoDiQBZwRsShUn60LN/9oQ=
=zvAY
-END PGP SIGNATURE-
-- 
http://mail.python.org/mailman/listinfo/python-list


Custom class to a dictionary?

2008-01-26 Thread Oliver Beattie
Just wondering if it is possible to pass a custom class instance
instance to dict() by way of using methods like you can for iterators
(__iter__, __getitem__ etc.) I see there is no __dict__ -- is there
anything else I can use to achieve this?

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


  1   2   >