Re: for -- else: what was the motivation?

2022-10-10 Thread Calvin Spealman
On Sat, Oct 8, 2022 at 5:35 PM rbowman  wrote:

> On 10/7/22 21:32, Axy wrote:
> > So, seriously, why they needed else if the following pieces produce same
> > result? Does anyone know or remember their motivation?
>
> In real scenarios there would be more logic in the for block that would
> meet a condition and break out of the loop. If the condition is never
> met, the else block runs. To steal from w3schools:
>
>
> fruits = ["apple", "peach", "cherry"]
> for x in fruits:
>print(x)
>if x == "banana":
>  break
> else:
>print("Yes we got no bananas")
>

I wonder if for/else could have been less confusing if it was referred to
as for-break-else and if the else clause was only valid syntax if the for
loop actually contained a break statement in the first place.

-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

calvin.speal...@redhat.com  M: +1.336.210.5107
[image: https://red.ht/sig] <https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: venv and packages with entry points

2022-09-06 Thread Calvin Spealman
Each virtual environment has its own bin/ directory and when activated its
bin/ is in your $PATH

On Tue, Sep 6, 2022 at 1:45 PM  wrote:

> Hello,
>
> I try to get it onto my head how virtual environments (via venv) works
> when I have packages with "entry points".
>
> I can define such entry points in the setup.cfg like this (full example
> [1]):
>
> [options.entry_points]
> console_scripts =
>  hyperorg = hyperorg.__main__:main
>
> When I install such a package via pip the result is a shell script in
> /usr/bin/...
>
> What happens when I install such a package with an entry point via "pip
> install ." when an virtual environment is activated?
>
> Kind
> Christian
>
> [1] --
> <https://codeberg.org/buhtz/hyperorg/src/branch/develop/setup.cfg>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
>

-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

calvin.speal...@redhat.com  M: +1.336.210.5107
[image: https://red.ht/sig] <https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: WHAT THE ERROR ON MY CODE???

2022-06-29 Thread Calvin Spealman
You also forgot to include any information about an error or problem you
got in using this code.

We can't help you if you don't have an actual question to ask.

‪On Wed, Jun 29, 2022 at 1:36 AM ‫נתי שטרן‬‎  wrote:‬

> Sorry but i forgor to delete this token data
>
> בתאריך יום שלישי, 28 ביוני 2022, מאת De ongekruisigde <
> ongekruisi...@news.eternal-september.org>:
>
> > On 2022-06-28, Chris Angelico  wrote:
> > > ‪On Wed, 29 Jun 2022 at 01:37, ‫נתי שטרן‬‎  wrote:‬
> > >> headers["Authorization"] = "Basic
> > >> YjMwMzcwODY3NTUzNDMwNTg5NzA2MjkyNDFmMDE1YWY6VjNKYTk2Y1F4RTFz
> > eTdYbzRnbkt0a2k1djhscXUyU01oSE5VWUwwRg=="
> > >>
> > >
> > > The error is that you just revealed your credentials to the whole
> > > world. This is a public mailing list.
> > >
> > > In fact, you just revealed your credentials to TWO mailing lists at
> once.
> >
> > I think the term 'script kiddie' applies here.
> >
> >
> > > Good job.
> > >
> > > ChrisA
> >
> >
> > --
> > Without followers, evil cannot spread.
> >
> > [Spock, "And The Children Shall Lead", stardate 5029.5]
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> >
>
>
> --
> <https://netanel.ml>
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

calvin.speal...@redhat.com  M: +1.336.210.5107
[image: https://red.ht/sig] <https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why There Is No Python Compressed Archive or Binaries ?

2022-01-17 Thread Calvin Spealman
Well, on its own, I'd say the reason we don't have such a download is that
it wouldn't be very useful.

On Mon, Jan 17, 2022 at 2:08 PM Sina Mobasheri 
wrote:

> It's cool project definitely something that I'm personally interested
> about, but I talking about compressed archive of cpython that we can simply
> unzipped and starting developing an app, not running  an app that already
> developed... 
> --
> *From:* Calvin Spealman 
> *Sent:* Monday, January 17, 2022 10:19:13 PM
> *To:* Sina Mobasheri 
> *Cc:* python-list@python.org 
> *Subject:* Re: Why There Is No Python Compressed Archive or Binaries ?
>
> I maintain a small project that provides this, a drop-in Python runtime
> you can ship without installation called Feet. Get it? It makes Python run.
>
> https://github.com/ironfroggy/feet
>
> On Mon, Jan 17, 2022 at 11:16 AM Sina Mobasheri 
> wrote:
>
> Java offers download JDK as Compressed Archive<
> https://www.oracle.com/java/technologies/downloads/#jdk17-linux> or
> NodeJS offers download Node as Binaries<
> https://nodejs.org/en/download/current/> both give us a compressed file
> for Linux and windows that we can just unzipped it and put in a custom
> directory and set some environment variables and start working
>
> I'm aware that Python also have something called Embedded Zip<
> https://www.python.org/ftp/python/3.10.1/python-3.10.1-embed-amd64.zip>
> for Windows and nothing like that for Linux as far as I know, and I think
> this Embedded Zip is not something that user wants to work with that
> directly it's for embedding in a C++ application, so it's not the same as
> options that Java and NodeJS offers
>
> My question is why Python hasn't option for downloading as Compressed
> Archive ?
> --
> https://mail.python.org/mailman/listinfo/python-list
>
>
>
> --
>
> CALVIN SPEALMAN
>
> SENIOR QUALITY ENGINEER
>
> calvin.speal...@redhat.com  M: +1.336.210.5107
> [image: https://red.ht/sig] <https://red.ht/sig>
> TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
>


-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

calvin.speal...@redhat.com  M: +1.336.210.5107
[image: https://red.ht/sig] <https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why There Is No Python Compressed Archive or Binaries ?

2022-01-17 Thread Calvin Spealman
I maintain a small project that provides this, a drop-in Python runtime you
can ship without installation called Feet. Get it? It makes Python run.

https://github.com/ironfroggy/feet

On Mon, Jan 17, 2022 at 11:16 AM Sina Mobasheri 
wrote:

> Java offers download JDK as Compressed Archive<
> https://www.oracle.com/java/technologies/downloads/#jdk17-linux> or
> NodeJS offers download Node as Binaries<
> https://nodejs.org/en/download/current/> both give us a compressed file
> for Linux and windows that we can just unzipped it and put in a custom
> directory and set some environment variables and start working
>
> I'm aware that Python also have something called Embedded Zip<
> https://www.python.org/ftp/python/3.10.1/python-3.10.1-embed-amd64.zip>
> for Windows and nothing like that for Linux as far as I know, and I think
> this Embedded Zip is not something that user wants to work with that
> directly it's for embedding in a C++ application, so it's not the same as
> options that Java and NodeJS offers
>
> My question is why Python hasn't option for downloading as Compressed
> Archive ?
> --
> https://mail.python.org/mailman/listinfo/python-list
>
>

-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

calvin.speal...@redhat.com  M: +1.336.210.5107
[image: https://red.ht/sig] <https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: NOT ABLE TO SEE PICTURES

2021-12-01 Thread Calvin Spealman
What does "python runs in file explorer" mean? How do you know its the same
folder? How are you looking at the contents of the folder?

On Wed, Dec 1, 2021 at 10:33 AM Ragavendar  wrote:

>When the python runs in file explorer when I open a folder it shows NO
>ITEAMS FOUND and if I open same folder without python ITEAMS ARE THERE
> so
>kindly help me
>
>
>
>
>
>Sent from [1]Mail for Windows
>
>
>
> References
>
>Visible links
>1. https://go.microsoft.com/fwlink/?LinkId=550986
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

calvin.speal...@redhat.com  M: +1.336.210.5107
[image: https://red.ht/sig] <https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Failure to Display Top menu

2021-11-29 Thread Calvin Spealman
This mailing list does not allow attachments. If you're trying to share a
screenshot, post it to imgur or something like that and share a URL here.

On Mon, Nov 29, 2021 at 2:12 PM Peter Mwale  wrote:

> Hello Christian,
> Am referring to menu marked in picture below. It's not coming on my window.
>
>
> On Sat, Nov 27, 2021, 20:19 Christian Gollwitzer  wrote:
>
> > Am 26.11.21 um 21:38 schrieb Peter Mwale:
> > > Hello, my python 3.10 shell is not displaying the top menu. What
> should I
> > > do?
> > >
> >
> > You should explain, what you do exactly. The Python interpreter does not
> > have a menu.
> >
> > a) What platform are you on? Windows, macOS, Linux?
> >
> > b) How did ou start Python and what was the expectation?
> >
> > Christian
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> >
> --
> https://mail.python.org/mailman/listinfo/python-list
>
>

-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

calvin.speal...@redhat.com  M: +1.336.210.5107
[image: https://red.ht/sig] <https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pyinstaller: icon not visable on desktop?

2021-11-24 Thread Calvin Spealman
What version of Windows is this on? That's probably going to be a useful
bit of information, because there could be differences there to how EXE
icons are handled.

On Tue, Nov 23, 2021 at 4:18 PM Ulli Horlacher <
frams...@rus.uni-stuttgart.de> wrote:

> When I compile a python program with pyinstaller, I get an executable:
>
> pyinstaller --onefile --icon fex.ico fextasy.py
>
> But the executables icon is only visable within the windows file browser,
> not on the desktop:
>
> https://fex.flupp.org/fop/V2ioMZcl/X-20211123213712.png
>
> There is only the default pyinstaller icon.
>
> Why?
>
>
> --
> Ullrich Horlacher  Server und Virtualisierung
> Rechenzentrum TIK
> Universitaet Stuttgart E-Mail: horlac...@tik.uni-stuttgart.de
> Allmandring 30aTel:++49-711-68565868
> 70569 Stuttgart (Germany)  WWW:http://www.tik.uni-stuttgart.de/
> --
> https://mail.python.org/mailman/listinfo/python-list
>
>

-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

calvin.speal...@redhat.com  M: +1.336.210.5107
[image: https://red.ht/sig] <https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why so fast a web framework?

2021-10-28 Thread Calvin Spealman
I don't think there's anything meaningful being compared in that so-called
"benchmark" at all. There is no evidence that its worth even the smallest
bit of attention.

You want to write a web service? Do it. Use Python or PHP, or whatever you
prefer. Do you think your service is "slow"? You won't know until you
measure *your* service and compare that against actual requirements you
have. There is no context here to discuss performance and performance can
*only* be discussed in a context.

"SQL queries per second" is pointless. Why are you making so many SQL
queries? If you want your service to be more efficient, make fewer queries!

On Thu, Oct 28, 2021 at 12:49 PM Abdur-Rahmaan Janhangeer <
arj.pyt...@gmail.com> wrote:

> Me
>
> Like why exactly is that the case, i would not be surprised for rust, C,
> CPP etc
> But as to where the difference comes for two comparatively similar langs.
>
> Kind Regards,
>
> Abdur-Rahmaan Janhangeer
> about <https://compileralchemy.github.io/> | blog
> <https://www.pythonkitchen.com>
> github <https://github.com/Abdur-RahmaanJ>
> Mauritius
>


-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

calvin.speal...@redhat.com  M: +1.336.210.5107
[image: https://red.ht/sig] <https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why so fast a web framework?

2021-10-28 Thread Calvin Spealman
Who cares?

On Wed, Oct 27, 2021 at 10:47 PM Abdur-Rahmaan Janhangeer <
arj.pyt...@gmail.com> wrote:

> @Chris @Peter
>
>
> See that famous benchmark
>
> https://www.techempower.com/benchmarks/#section=data-r20
>
> Like routinely PHP frameworks appear higher up than py
> --
> https://mail.python.org/mailman/listinfo/python-list
>
>

-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

calvin.speal...@redhat.com  M: +1.336.210.5107
[image: https://red.ht/sig] <https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Request for argmax(list) and argmin(list)

2021-09-01 Thread Calvin Spealman
If only there were a library that already provides exactly the functions
you're asking for... 樂

On Wed, Sep 1, 2021 at 9:54 AM ABCCDE921 
wrote:

> Because that does 2 passes over the entire array when you only need one
> and there is no option to specify if you want the leftmost or rightmost
> element
>
>
> On Wednesday, September 1, 2021 at 12:02:29 PM UTC+5:30, Paul Bryan wrote:
> > Why not:
> >
> > >>> l = [1, 3, 5, 9, 2, 7]
> > >>> l.index(max(l))
> > 3
> > >>> l.index(min(l))
> > 0
> > On Tue, 2021-08-31 at 21:25 -0700, ABCCDE921 wrote:
> > > I dont want to import numpy
> > >
> > > argmax(list)
> > > returns index of (left most) max element
> > >
> > > argmin(list)
> > > returns index of (left most) min element
> --
> https://mail.python.org/mailman/listinfo/python-list
>
>

-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

calvin.speal...@redhat.com  M: +1.336.210.5107
[image: https://red.ht/sig] <https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PEP Idea: Real private attribute

2021-09-01 Thread Calvin Spealman
On Tue, Aug 31, 2021 at 1:19 PM Mehrzad Saremi 
wrote:

> Calvin, even if the language offered truly private members?
>

I'm saying I don't think they're necessary, especially not for the use case
posited here. Private members in other languages are about things internal
to the class of the object itself. If we *did* have them in Python, you
couldn't use private members of an object from a decorator on it because
the decorator is external to the target class.


> On Tue, 31 Aug 2021 at 17:31, Calvin Spealman  wrote:
>
>> The right way for those decorators to hold some private information,
>> imho, isn't to put anything on the decorated object at all, but to use a
>> weak-ref dictionary using the target object as a key.
>>
>> On Sat, Aug 28, 2021 at 5:42 PM Mehrzad Saremi 
>> wrote:
>>
>>> Python currently uses name mangling for double-underscore attributes.
>>> Name
>>> mangling is not an ideal method to avoid name conflicting. There are
>>> various normal programming patterns that can simply cause name
>>> conflicting
>>> in double-underscore members. A typical example is when a class is
>>> re-decorated using the same decorator. The decorator can not take
>>> double-underscore members without name conflicts. For example:
>>>
>>> ```
>>> @custom_decorator("a")
>>> @custom_decorator("b")
>>> class C:
>>> pass
>>> ```
>>>
>>> The `@custom_decorator` wrapper may need to hold private members, but
>>> Python's current name conflict resolution does not provide any solution
>>> and
>>> the decorator cannot hold private members without applying tricky
>>> programming methods.
>>>
>>> Another example is when a class inherits from a base class of the same
>>> name.
>>>
>>> ```
>>> class View:
>>> """A class representing a view of an object; similar to
>>> numpy.ndarray.view"""
>>> pass
>>>
>>> class Object:
>>> class View(View):
>>> """A view class costumized for objects of type Object"""
>>> pass
>>> ```
>>>
>>> Again, in this example, class `Object.View` can't take double-underscore
>>> names without conflicting with `View`'s.
>>>
>>> My idea is to introduce real private members (by which I do not mean to
>>> be
>>> inaccessible from outside the class, but to be guaranteed not to conflict
>>> with other private members of the same object). These private members are
>>> started with triple underscores and are stored in a separate dictionary
>>> named `__privs__`. Unlike `__dict__` that takes 'str' keys, `__privs__`
>>> will be a double layer dictionary that takes 'type' keys in the first
>>> level, and 'str' keys in the second level.
>>>
>>> For example, assume that the user runs the following code:
>>> ```
>>> class C:
>>> def __init__(self, value):
>>> self.___member = value
>>>
>>> c = C("my value")
>>> ```
>>>
>>> On the last line, Python's attribute setter creates a new entry in the
>>> dictionary with key `C`, adds the value "my value" to a new entry with
>>> the
>>> key 'member'.
>>>
>>> The user can then retrieve `c.___member` by invoking the `__privs__`
>>> dictionary:
>>>
>>> ```
>>> print(c.__privs__[C]['member'])  # prints 'my value'
>>> ```
>>>
>>> Note that, unlike class names, class objects are unique and there will
>>> not
>>> be any conflicts. Python classes are hashable and can be dictionary keys.
>>> Personally, I do not see any disadvantage of using __privs__ over name
>>> mangling/double-underscores. While name mangling does not truly guarantee
>>> conflict resolution, __privs__ does.
>>>
>>> Please discuss the idea, let me know what you think about it, whether
>>> there
>>> are possible disadvantages, and if you think it will be approved as a
>>> PEP.
>>>
>>> Thanks,
>>> Mehrzad Saremi
>>>
>>> AI M.Sc. grad. from AUT
>>> --
>>> https://mail.python.org/mailman/listinfo/python-list
>>>
>>>
>>
>> --
>>
>> CALVIN SPEALMAN
>>
>> SENIOR QUALITY ENGINEER
>>
>> calvin.speal...@redhat.com  M: +1.336.210.5107
>> [image: https://red.ht/sig] <https://red.ht/sig>
>> TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
>>
>

-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

calvin.speal...@redhat.com  M: +1.336.210.5107
[image: https://red.ht/sig] <https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PEP Idea: Real private attribute

2021-08-31 Thread Calvin Spealman
The right way for those decorators to hold some private information, imho,
isn't to put anything on the decorated object at all, but to use a weak-ref
dictionary using the target object as a key.

On Sat, Aug 28, 2021 at 5:42 PM Mehrzad Saremi 
wrote:

> Python currently uses name mangling for double-underscore attributes. Name
> mangling is not an ideal method to avoid name conflicting. There are
> various normal programming patterns that can simply cause name conflicting
> in double-underscore members. A typical example is when a class is
> re-decorated using the same decorator. The decorator can not take
> double-underscore members without name conflicts. For example:
>
> ```
> @custom_decorator("a")
> @custom_decorator("b")
> class C:
> pass
> ```
>
> The `@custom_decorator` wrapper may need to hold private members, but
> Python's current name conflict resolution does not provide any solution and
> the decorator cannot hold private members without applying tricky
> programming methods.
>
> Another example is when a class inherits from a base class of the same
> name.
>
> ```
> class View:
> """A class representing a view of an object; similar to
> numpy.ndarray.view"""
> pass
>
> class Object:
> class View(View):
> """A view class costumized for objects of type Object"""
> pass
> ```
>
> Again, in this example, class `Object.View` can't take double-underscore
> names without conflicting with `View`'s.
>
> My idea is to introduce real private members (by which I do not mean to be
> inaccessible from outside the class, but to be guaranteed not to conflict
> with other private members of the same object). These private members are
> started with triple underscores and are stored in a separate dictionary
> named `__privs__`. Unlike `__dict__` that takes 'str' keys, `__privs__`
> will be a double layer dictionary that takes 'type' keys in the first
> level, and 'str' keys in the second level.
>
> For example, assume that the user runs the following code:
> ```
> class C:
> def __init__(self, value):
> self.___member = value
>
> c = C("my value")
> ```
>
> On the last line, Python's attribute setter creates a new entry in the
> dictionary with key `C`, adds the value "my value" to a new entry with the
> key 'member'.
>
> The user can then retrieve `c.___member` by invoking the `__privs__`
> dictionary:
>
> ```
> print(c.__privs__[C]['member'])  # prints 'my value'
> ```
>
> Note that, unlike class names, class objects are unique and there will not
> be any conflicts. Python classes are hashable and can be dictionary keys.
> Personally, I do not see any disadvantage of using __privs__ over name
> mangling/double-underscores. While name mangling does not truly guarantee
> conflict resolution, __privs__ does.
>
> Please discuss the idea, let me know what you think about it, whether there
> are possible disadvantages, and if you think it will be approved as a PEP.
>
> Thanks,
> Mehrzad Saremi
>
> AI M.Sc. grad. from AUT
> --
> https://mail.python.org/mailman/listinfo/python-list
>
>

-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

calvin.speal...@redhat.com  M: +1.336.210.5107
[image: https://red.ht/sig] <https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Website

2021-04-15 Thread Calvin Spealman
The PSF guidelines on trademark usage are generous and well documented
here: https://www.python.org/psf/trademarks/

Good luck with your website!

On Wed, Apr 14, 2021 at 11:43 AM Rainyis  wrote:

> Hello,
> I am Sergio Llorente, and I want to create a web about python. I
> will publish apps, scripts.. made by python. I will like to put python in
> the domain. The domain will be like all-about-python.com but in Spanish(
> todosobrepython.com). Can I use it?
>
> Thanks in advance,
> Sergio
> --
> https://mail.python.org/mailman/listinfo/python-list
>
>

-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

calvin.speal...@redhat.com  M: +1.336.210.5107
[image: https://red.ht/sig] <https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Output showing "None" in Terminal

2020-08-24 Thread Calvin Spealman
How are you actually running your code?

"None" is the default return value of all functions in Python. But, the
interpreter is supposed to suppress it as a displayed result.

As a side note, both your km_mi() function and the line "answer = km_mi"
are certainly wrong, but it is not clear what you intend to do.

On Mon, Aug 24, 2020 at 4:25 PM Py Noob  wrote:

> Hi!
>
> i'm new to python and would like some help with something i was working on
> from a tutorial. I'm using VScode with 3.7.0 version on Windows 7. Below is
> my code and the terminal is showing the word "None" everytime I execute my
> code.
>
> Many thanks!
>
> print("Conversion")
>
> def km_mi():
> return answer
>
> selection = input("Type mi for miles or km for kilometers: ")
>
> if selection == "mi":
> n = int(input(print("Please enter distance in miles: ")))
> answer = (1.6*n)
> print("%.2f" % answer, "miles")
>
> else:
> n = float(input(print("Please enter distance in kilometers: ")))
> answer = (n/1.6)
> print("%.2f" % answer, "kilometers")
>
> answer = km_mi
> --
> https://mail.python.org/mailman/listinfo/python-list
>
>

-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspea...@redhat.com  M: +1.336.210.5107
[image: https://red.ht/sig] <https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Final statement from Steering Council on politically-charged commit messages

2020-08-19 Thread Calvin Spealman
Tim,

Technology is political. Deal with it.

Signed,
Common Fucking Sense

On Wed, Aug 19, 2020 at 4:02 PM Tim Daneliuk  wrote:

> On 8/19/20 1:10 PM, J. Pic wrote:
> > Tim, don't you also think that statements should be backed by
> > evidence, even more if they are particularly accusatory ?
> >
> > We'll be lucky if S's editor doesn't sue the PSF for slandering for
> > publishing that S "upholds white supremacy".
> >
>
> As a general matter, I agree: Claims should be supported by evidence.
> But that's not the problem here.  The various cause crusaders are
> attempting to insert themselves into every single discipline.  They
> do this claiming their attacks as some kind of moral virtue and that
> they are therefore above reproach or counterpoint.  It is natural
> for people who disagree to punch back.
>
> My real point in commenting at all was that we open this one-sided door
> at our own peril. By allowing provocative commentary of the sort voice
> in this godforsaken commit message, we absolutely invite others to the
> party.
> Despite what the aforementioned cause crusaders think, they are not
> unassailable, nor are they the only- or dominant voice in these matters.
> Open this door and you get an absolute sewer of commentary
> (from many sides of these issues).  Social media is full of many trenchant
> such examples.  Best to leave it there.
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
>

-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspea...@redhat.com  M: +1.336.210.5107
[image: https://red.ht/sig] <https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: i don't understand this python class

2020-06-29 Thread Calvin Spealman
You are misreading the original example. `init_network` is defined as a
method on the class, and called in its initializer. There is no property
named "init_network".

On Mon, Jun 29, 2020 at 1:18 PM joseph pareti  wrote:

> I have piece of code with constructs as follows:
>
> *class* *SentimentNetwork**:*
>
> *def* __init__*(*self*,* reviews*,* labels*,* hidden_nodes *=* 10*,*
> learning_rate *=* 0.1*):*
>
>
>
> np*.*random*.*seed*(*1*)*
>
>
>
>self*.*init_network*(**len**(*self*.*review_vocab*),*hidden_nodes*,*
> 1*,* learning_rate*)*
>
>
>
>
>
>
>
> *def* init_network*(*self*,* input_nodes*,* hidden_nodes*,*
> output_nodes
> *,* learning_rate*):*
>
> # Store the number of nodes in input, hidden, and output layers.
>
> self*.*input_nodes *=* input_nodes
>
> self*.*hidden_nodes *=* hidden_nodes
>
> self*.*output_nodes *=* output_nodes
>
> which makes me think about the redundant usage of* init_network:*
>
>1. as a method, AND
>2. as a property
>
> So far I have only seen codes where the 2 things are separated, e.g. :
>
> *import* insurance *as* ins
>
> *class* *Vehicle**:*
>
> *def* __init__*(*self*,* speed*,* make*):*
>
> self*.*speed *=* speed
>
> self*.*make *=* make
>
> *class* *car**(*Vehicle*):*
>
> *def* __init__*(*self*,* speed*,* make*):*
>
> Vehicle*.*__init__*(*self*,* speed*,* make*)*
>
> self*.*insurance *=* ins*.*calc*(*make*)*
>
> *def* show_out*(*self*):*
>
> *print**(*'vehicle is '*,*self*.*make*,*' insurance premium
> '*,*self
> *.*insurance*)*
>
> *def* claim*(*self*,* discount*):*
>
> X *=* self*.*insurance *+* discount
>
> *return* X
>
>
> And hence I am not sure about the behavior of the first code in this email.
> --
> Regards,
> Joseph Pareti - Artificial Intelligence consultant
> Joseph Pareti's AI Consulting Services
> https://www.joepareti54-ai.com/
> cell +49 1520 1600 209
> cell +39 339 797 0644
> --
> https://mail.python.org/mailman/listinfo/python-list
>
>

-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspea...@redhat.com  M: +1.336.210.5107
[image: https://red.ht/sig] <https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pyinstaller

2020-06-10 Thread Calvin Spealman
On Wed, Jun 10, 2020 at 10:06 AM Chris Angelico  wrote:

> On Wed, Jun 10, 2020 at 11:49 PM Robin Becker  wrote:
> >
> > I'm sure this has come up before, but a tiny pyinstaller created exe is
> being seen as malware by windows 10.
> >
> > Is there any way to create simple single file applications which don't
> get this treatment?
> >
> > The intended users are unlikely to understand how to adjust the scanner
> to whitelist the application.
>
> Tell them to install Python from an official source, and then
> distribute your application as a single .py (or .pyw) file. Problem
> solved.
>

This is in no way a solution or a reasonable way to distribute software to
end-users. Please don't give non-answers.

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

-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspea...@redhat.com  M: +1.336.210.5107
[image: https://red.ht/sig] <https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: about to resolve problem in installation

2020-03-31 Thread Calvin Spealman
You are trying to run the installer after you've already installed Python.

Instead, you want to open your start menu and search for Python or IDLE
(the Python editor) to actually run and use the Python version you've
already installed.

On Tue, Mar 31, 2020 at 8:22 AM Kapuganti Rakesh <
kapugantirakesh...@gmail.com> wrote:

> Respected sir,
>  I have downloaded the latest version of python 3.8.2
> in my windows 10. I have installed that.After completion of installation
> process it is displaying three options of modify,repair and uninstall. How
> to resolve that issue. please help me
>Thanking You
> --
> https://mail.python.org/mailman/listinfo/python-list
>
>

-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspea...@redhat.com  M: +1.336.210.5107
[image: https://red.ht/sig] <https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Not Running from Kindle

2020-03-31 Thread Calvin Spealman
There is no official Python app download for Kindle fire. If that's what
you've found and are trying to use, you'll need to contact the developer
responsible. If you want the official distribution of Python, you can
download it from python.org on a Windows, Mac, or Linux PC.

On Tue, Mar 31, 2020 at 8:26 AM if only  wrote:

> I’m following the Kindle download and get to writing hello world but that
> does not get to my command window?
>
>
> J Carrod
>
> Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for
> Windows 10
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
>

-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspea...@redhat.com  M: +1.336.210.5107
[image: https://red.ht/sig] <https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: problem occurring in operating python , after typing only 5-6 programs only is causing problem it has stoped working

2019-09-03 Thread Calvin Spealman
You will need to provide more information:

What version of Python are running?

What sort of error message you receiving (paste the entire error)?

What code are you attempting to run which causes this problem (paste the
failing code)?

On Sun, Sep 1, 2019 at 3:01 PM best web site 
wrote:

>
>
> Sent from Mail for Windows 10
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspea...@redhat.com  M: +1.336.210.5107
[image: https://red.ht/sig] <https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help needed to run some code!!!!

2019-09-03 Thread Calvin Spealman
client.run()
>
> client.loop_start()  # start the loop
> device_message = self.fileName_UI
> time.sleep(2)
> print("Subscribing to topic",
> "microscope/light_sheet_microscope/UI")
> client.subscribe("microscope/light_sheet_microscope/UI")
> print("Publishing message to topic",
> "microscope/light_sheet_microscope/UI")
> client.publish("microscope/light_sheet_microscope/UI",
> json.dumps({"type": "device", "payload":{"name": self.fileName_UI}},
> indent=2))
> time.sleep(2)  # wait
> client.loop_stop()  # stop the loop
> print(device_message + ".py " + "file doesn't exist")
> print("Device not added")
> if __name__ == "__main__":
> app = QApplication(sys.argv)
> mainWin = MainWindow()
> a = mainWin.show()
> try:
> mainWin.show()
> os.remove("list_of_devices.txt")
> print("Awaiting devices to be launched")
> except:
> print("Awaiting devices to be launched")
> publishedMessage = mainWin.getGUIFilename()
> sys.exit(app.exec_())
>
> devicesEmbedded.py:
>
> import random
> import asyncio
> from actorio import Actor, Message, DataMessage, ask, EndMainLoop,
> Reference
> from mqtt import *
> # from GUI import *
>
> client = device("Device")
> client.run()
> client.loop_start()
> time.sleep(1)
>
> print("Subscribing to topic",
> "microscope/light_sheet_microscope/UI/list_of_devices")
> client.subscribe("microscope/light_sheet_microscope/UI/list_of_devices")
> client.loop_stop()  # stop the loop
>
> def readFile(fname):
> try:
> with open(fname, "r") as f:
> for item in f:
> print(item)
> except:
> print("No devices added yet")
> readFile("list_of_devices.txt")
>
> mqtt.py
>
> import logging
> from datetime import timedelta
> import time
> from thespian.actors import *
> from transitions import Machine
> import paho.mqtt.client as mqtt
> import importlib
> import os.path
> import sys
> from PyQt5.QtWidgets import *
> from PyQt5.QtCore import *
> from PyQt5 import QtWidgets, uic
>
> class device(mqtt.Client):
> def on_connect(self, mqttc, obj, flags, rc):
> if rc == 0:
> print("Connected to broker")
> else:
> print("Connection failed")
>
> # mqttc.subscribe("microscope/light_sheet_microscope/UI")
>
> def on_message(self, mqttc, userdata, message):
> msg = str(message.payload.decode("utf-8"))
> print("message recieved= " + msg)
> # print("File which you want to import(with .py extension)")
> print("message topic=", message.topic)
> print("message qos=", message.qos)
> print("message retain flag=", message.retain)
>
> def run(self):
> self.connect("broker.hivemq.com", 1883, 60)
>
> Thanks
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspea...@redhat.com  M: +1.336.210.5107
[image: https://red.ht/sig] <https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: An "Object" class?

2019-08-27 Thread Calvin Spealman
`type` is the "class" class (type and class are more or less synonymous
terms in modern Python).

You can find many of Python's implementation types in the `types` library,
including `FunctionType`, here: https://docs.python.org/3/library/types.html

On Tue, Aug 27, 2019 at 2:19 PM Cristian Cocos  wrote:

> Thank you! What would be the names of the *class *class, and of the
> *function
> *class please?
>
> On Tue, Aug 27, 2019 at 1:39 PM Calvin Spealman 
> wrote:
>
> > Yes, it is called `object` and `object` is the base class of ALL other
> > classes, including `type`. In fact, it is the only class which does not
> > itself inherit from anything.
> >
> > On Tue, Aug 27, 2019 at 1:35 PM Cristian Cocos  wrote:
> >
> >> I know that "Everything is an object in python" as per
> >> https://mail.python.org/pipermail/python-list/2015-June/691689.html.
> >> Also,
> >> I am more-or-less convinced that there is a generic "class" (aka "type")
> >> (meta)class (which would be an object, of course). Is there, however, a
> >> generic "object" (meta)class (which would obviously be an object as well
> >> as
> >> a class)?
> >>
> >> Christian
> >>
> >> --
> >> "People think that I must be a very strange person. This is not
> correct. I
> >> have the heart of a small boy. It is in a glass jar on my desk." --
> >> Stephen
> >> King
> >> --
> >> https://mail.python.org/mailman/listinfo/python-list
> >>
> >
> >
> > --
> >
> > CALVIN SPEALMAN
> >
> > SENIOR QUALITY ENGINEER
> >
> > cspea...@redhat.com  M: +1.336.210.5107
> > [image: https://red.ht/sig] <https://red.ht/sig>
> > TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
> >
>
>
> --
> "People think that I must be a very strange person. This is not correct. I
> have the heart of a small boy. It is in a glass jar on my desk." -- Stephen
> King
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspea...@redhat.com  M: +1.336.210.5107
[image: https://red.ht/sig] <https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: An "Object" class?

2019-08-27 Thread Calvin Spealman
Yes, it is called `object` and `object` is the base class of ALL other
classes, including `type`. In fact, it is the only class which does not
itself inherit from anything.

On Tue, Aug 27, 2019 at 1:35 PM Cristian Cocos  wrote:

> I know that "Everything is an object in python" as per
> https://mail.python.org/pipermail/python-list/2015-June/691689.html. Also,
> I am more-or-less convinced that there is a generic "class" (aka "type")
> (meta)class (which would be an object, of course). Is there, however, a
> generic "object" (meta)class (which would obviously be an object as well as
> a class)?
>
> Christian
>
> --
> "People think that I must be a very strange person. This is not correct. I
> have the heart of a small boy. It is in a glass jar on my desk." -- Stephen
> King
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspea...@redhat.com  M: +1.336.210.5107
[image: https://red.ht/sig] <https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: itertools cycle() docs question

2019-08-21 Thread Calvin Spealman
The point is to demonstrate the effect, not the specific implementation.

On Wed, Aug 21, 2019 at 2:30 PM Tobiah  wrote:

> In the docs for itertools.cycle() there is
> a bit of equivalent code given:
>
>  def cycle(iterable):
>  # cycle('ABCD') --> A B C D A B C D A B C D ...
>  saved = []
>  for element in iterable:
>  yield element
>  saved.append(element)
>  while saved:
>  for element in saved:
>  yield element
>
>
> Is that really how it works?  Why make
> the copy of the elements?  This seems
> to be equivalent:
>
>
>  def cycle(iterable):
>  while iterable:
>  for thing in iterable:
>  yield thing
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspea...@redhat.com  M: +1.336.210.5107
[image: https://red.ht/sig] <https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: About the #python irc channel on freenode.

2019-08-13 Thread Calvin Spealman
The #python channel only allows registered Freenode users in. You can learn
about registration on Freenode here:
https://freenode.net/kb/answer/registration

Once you've got a registered account you can join #python and should find
many helpful people ready to help you.

On Mon, Aug 12, 2019 at 8:00 PM Hongyi Zhao  wrote:

> On Mon, 12 Aug 2019 16:13:41 -0700, Paul Rubin wrote:
>
> > It's always worked ok for me.
>
> But I always be put into the #python-unregistered channel as follows:
>
> --
> Now talking on #python-unregistered
> * Topic for #python-unregistered is: Welcome to #python-unregistered!
> You've been put here because #python requires you to register your
> nickname with Freenode. For more information about registering on
> Freenode, ask #freenode. For more information about #python,#python-*
> moderation, #python-ops.
> * Topic for #python-unregistered set by lvh!~lvh@python/psf/lvh (Fri Jul
> 1 16:44:19 2011)
> -
>
> I've tried to register the nickname as it told. But still cannot success.
>
> Regards
> --
> .: Hongyi Zhao [ hongyi.zhao AT gmail.com ] Free as in Freedom :.
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspea...@redhat.com  M: +1.336.210.5107
[image: https://red.ht/sig] <https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: PEP: add a `no` keyword as an alias for `not`

2019-08-01 Thread Calvin Spealman
I think they actually read like they would mean slightly different things,
which would make them existing as aliases confusing.

I read `if not val` as "If val isn't true" but i would read `if no val` as
"if val does not exist"

On Thu, Aug 1, 2019 at 4:07 PM Daniel Okey-Okoro 
wrote:

> I think that adding a `no` keyword as an alias for `not` would make for
> more readable, simple, pythonic code.
>
> Take the below:
>
> ```
> if not val:
>   do_thing_because_value_is_falsy()
> ```
>
> could be (is actually understood as):
>
> ```
> if no val:
>do_thing_because_value_is_falsy()
> ```
>
> I think this PEP is a work-around for an underlying subtle issue with how
> the `not` operator is used.
>
> It has two use-cases:
>
> 1. as a NOT gate for producing opposite boolean values
>
> ```
> opposite = not regular
> ```
>
> 2. as a sort of  ".is_falsy()"  checker; when used with an if statement.
>
> like the first example.
>
>
> This PEP would make the difference between the two usecases explicit.
>
> Thoughts?
>
> Best Intentions,
> Daniel Okey-Okoro.
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspea...@redhat.com  M: +1.336.210.5107
[image: https://red.ht/sig] <https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: newbie question

2019-08-01 Thread Calvin Spealman
Sorry, but you can't. If you have two python modules, neither has access to
things in the other without an import.

That's the whole point of an import.

On Thu, Aug 1, 2019 at 10:30 AM Sidney Langweil 
wrote:

> A Python script invokes a function in another file in the same directory.
>
> I would like to invoke that function without the need for an import.
>
> I think I read that having an empty __init__.py is sufficient.  But it
> does not seem to work for me.
>
> I'm sure this is obvious to many of you.  Thanks in advance for your help.
>
> Sid
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspea...@redhat.com  M: +1.336.210.5107
[image: https://red.ht/sig] <https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: List comprehension strangeness

2019-07-22 Thread Calvin Spealman
It is impossible to diagnose without seeing more context. Specifically,
you'll need to share the code around this line. The whole function,
preferably.

On Mon, Jul 22, 2019 at 9:31 AM Nicholas Cole 
wrote:

> I was profiling a slow function in an application last week, and came
> across something that I still can’t explain. Inside a loop that was being
> called 4 times, inside a for loop that ran for a few dozen times there was
> a list compression of the form:
>
> [x.id for x in some_function()]
>
> According to the profiler, some_function was being called 52,000 times —
> many, many times more than the few dozen it should have been. And sure
> enough, removing the comprehension did indeed speed up the function.
>
> It is very strange and feels like a possible bug in python. Has anyone ever
> encountered anything similar?
>
> Best wishes,
>
> Nicholas
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspea...@redhat.com  M: +1.336.210.5107
[image: https://red.ht/sig] <https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: issue

2019-07-10 Thread Calvin Spealman
If you could share the code you are trying to run, which is causing the
issue, someone might be able to help. Without that, it is doubtful you'll
get any help.

On Wed, Jul 10, 2019 at 11:08 AM joshua kay  wrote:

> Hello,
> i am encountering a issue with python 3.7.2rc1 64 bit currently
> My operating system is windows 10 and every time i try to run my code the
> shell just says:
> == RESTART: C:\Users\joshu\OneDrive\Desktop\python\projects\multi choice.py
> ==
>
> I how scanned the internet looking for a solution until i was made aware by
> the python installer about the support team, please tell me a solution for
> my issue
>
> thank you,
> Joshua kay
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspea...@redhat.com  M: +1.336.210.5107
[image: https://red.ht/sig] <https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Tkinter Button Command Taking Only Newest Reference In Callback Parameter

2019-07-08 Thread Calvin Spealman
This is a really common scoping issue to get tripped up on. I'll try to
help you understand and work around it.

for i, icon in enumerate(self.icons):
print('// entering', icon.program)
print('icons ... ... ... ...')
pretty(icon.info, icon.program)
x = Button(root, text=icon.info['name'] +'\n' + icon.info['version'],
   image=icon.photo,
compound=LEFT,
command=lambda: self.button_exec(icon))

On the first line you enter a for loop where each iteration assigns a
different pair of values to the names "i" and "icon".
On the last line you create a lambda, an anonymous function, which you pass
as the command callback for the button. Of course, no code inside the
lambda is actually executed at this point. It is only after the entire for
loop has completed, later when the user sees the buttons and clicks on one
of them, that one of the lambda callbacks for the appropriate button will
be executed.
Now, when this happens, what is the value of "icon"? This involves a
closure, which is how we describe the effect of the lambda (or any
function) being created inside the scope of another function. The scope
here which contains the "icon" variable is kept after the for loop and its
container function is complete, because the lambda you create holds on to
it in order to resolve variable names from. So all the lambda functions
read the "icon" variable from this same scope, and at the time the loop
completes that variable is assigned to the LAST value from the loop. That's
why all the buttons get the same icon.
There is a simple work around, however, called "rebinding". It is a trick
you can do with default values for lambda or any function. Simply pass the
icon as a default value for a parameter to the lambda, and the value at
that time for one iteration of the loop will be bound to the callback you
create.

Just change this

lambda: self.button_exec(icon)

to this

lambda icon=icon: self.button_exec(icon)

I hope both the explanation and the example help!


On Mon, Jul 8, 2019 at 1:59 AM Abdur-Rahmaan Janhangeer <
arj.pyt...@gmail.com> wrote:

> Greetings,
>
> I'm doing this project:
>
>
> https://github.com/Abdur-rahmaanJ/cmdlaunch/blob/master/cmdlaunch/cmdlaunch.py
>
> Everything works fine, except for one thing.
>
> On line 60, the button is taking an object in it's command parameter
>
> If you run the file, you'll see that all the different names are written on
> the gui just the callback is takest the newest icon object for all three
> buttons
>
> I know just a reference issue but it's been **bugging** me.
>
> Thanks All
>
> --
> Abdur-Rahmaan Janhangeer
> Mauritius
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspea...@redhat.com  M: +1.336.210.5107
[image: https://red.ht/sig] <https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do you insert an item into a dictionary (in python 3.7.2)?

2019-06-28 Thread Calvin Spealman
You simply assign to the key, like so:

dictionary[3] = 'value2'

But it isn't clear what you mean by "in the middle".

On Fri, Jun 28, 2019 at 11:10 AM CrazyVideoGamez 
wrote:

> How do you insert an item into a dictionary? For example, I make a
> dictionary called "dictionary".
>
> dictionary = {1: 'value1', 2: 'value3'}
>
> What if I wanted to add a value2 in the middle of value1 and value3?
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspea...@redhat.com  M: +1.336.210.5107
[image: https://red.ht/sig] <https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: No option available for saving files

2019-06-07 Thread Calvin Spealman
The python shell is good for experimenting and testing some things out, but
you are right it isn't for writing programs you actually re-use and run
later. You can use any text editor you want, Visual Studio Code and Sublime
Text are both popular, but anything will do at all. There is also a simple
editor with integration for running Python included in the Python Windows
installer, called IDLE. You should be able to find that in your start menu.

On Fri, Jun 7, 2019 at 4:24 AM Shreya Joshi 
wrote:

> Hi ma’am/sir,
> I’ve started using python Shell 3.6.8-32 bit executable installer on
> windows OS. But there is no option to save or open a new file. This gives
> an output after every line. But, I want to work on longer codes to execute
> programs.
>
> Am I using the right interface? Please help.
> Here is a screenshot…
>
> Sent from Mail for Windows 10
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspea...@redhat.com  M: +1.336.210.5107
[image: https://red.ht/sig] <https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: save files

2019-04-22 Thread Calvin Spealman
Can you give some more information about the problem and your setup,
including:

- What OS and OS version are you running?
- What is the Python script you are trying to write?
- Do you get the same behavior if you try to save an empty file?
- Can you confirm you are talking about Idle, the editor that comes with
Python, specifically?

On Mon, Apr 22, 2019 at 2:30 AM Franko rizai  wrote:

> -- Forwarded message -
> From: Franko rizai 
> Date: Sun, 21 Apr 2019 at 19:22
> Subject: save files
> To: 
>
>
> Hello i am new to python and i have an issue.I downloaded the python
> 3.7.3(32-bit) and i start working on it.I open a new window to write(new
> file) and its ok. But when I want to save it i press save or save us or F5
> ti run it, and it crashes, it stoppes working and tells me python has
> stopped working and close the program! If you can help me on this please!
> Thank you!
>
> <
> https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail
> >
> Απαλλαγμένο
> από ιούς. www.avast.com
> <
> https://www.avast.com/sig-email?utm_medium=email_source=link_campaign=sig-email_content=webmail
> >
> <#m_-8209034248381601832_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspea...@redhat.com  M: +1.336.210.5107
<https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Why inspect.isclass says iter() a class?

2019-04-10 Thread Calvin Spealman
Because it is. Many things are classes. calling itertools.chain(a, b)
creates an itertools.chain instance that you can iterate over. What else
did you think it would be?

On Wed, Apr 10, 2019 at 3:17 PM Arup Rakshit  wrote:

> From docs https://docs.python.org/3/library/itertools.html#itertools.chain
> I see that itertools.chain is defined as a function. But then why
> inspect.isclass(chain) is saying it as class.
>
> from itertools import chain
>
> inspect.isclass(chain)
> # True
>
>
> Thanks,
>
> Arup Rakshit
> a...@zeit.io
>
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspea...@redhat.com  M: +1.336.210.5107
<https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python os.chdir() Windows Error 2

2019-04-01 Thread Calvin Spealman
What are you actually trying to do?

os.chdir() simply changes the current working directory of your process. It
doesn't read any data or "import" or really have any affect on its own. The
current directory is the directory you ran the script from in the first
place, which is where files will be opened from. os.chdir() changes that
directory, affecting future files you access with open(), but doesn't have
a direct effect. Multiple chdir() calls in a row would simply be
meaningless.

On Mon, Apr 1, 2019 at 11:45 AM  wrote:

> Hey guys,
>
> I´ve got a problem importing a file with os.chdir. I´ve done a lot of
> research but still I can´t fix it. For any suggestions I would be so
> thankful!
>
> This is what I´ve tried so far:
>
> import os
> import numpy as np
> import matplotlib.pyplot as plt
>
>
> os.chdir('C:\Users\Ayla\Documents\Uni\Master_Umweltingenieurwesen\Study_Project\kerschbaum_input')
>
> os.chdir('C:\\Users\Ayla\Documents\Uni\Master_Umweltingenieurwesen\Study_Project\kerschbaum_input')
>
> os.chdir('C:\\Users\\Ayla\\Documents\\Uni\\Master_Umweltingenieurwesen\\Study_Project\\kerschbaum_input')
>
> os.chdir('C:/Users/Ayla/Documents/Uni/Master_Umweltingenieurwesen/Study_Project/kerschbaum_input')
>
> os.chdir('C://Users/Ayla/Documents/Uni/Master_Umweltingenieurwesen/Study_Project/kerschbaum_input')
>
> os.chdir('C://Users//Ayla//Documents//Uni/vMaster_Umweltingenieurwesen//Study_Project//kerschbaum_input')
>
> and each of these with [r'C:..'], " instead of ', and \\?\c instead of C.
> I also added the path (in advanced system settings) of the folder.
>
> Best regards
> Ayla
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspea...@redhat.com  M: +1.336.210.5107
<https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question regarding the local function object

2019-03-15 Thread Calvin Spealman
This is actually part of a not entirely uncommon misconception that can
arise by comparing objects only by their
repr() outputs (the string representation created when you pass them to
print).

You're comparing the ID or memory address of the objects and determining
they must be the same object. In this case,
it is a kind of illusion. The function is being garbage collected at the
end of each call to sort_by_last_letter() and then, on
the next call, that address is reused. It is just common for Python to take
the next available location, and that happens to
be the same because you're re-running generally the same code, so the same
number of objects are created and destroyed
each time.

You can see this by making a slight change: try keeping references to ALL
the created functions and you'll see they all
have different IDs so long as none of them get cleaned up. Try this
slightly modified version:

functions = []
def sort_by_last_letter(strings):
def last_letter(s):
return s[-1]
print(last_letter)
functions.append(last_letter)
return sorted(strings, key=last_letter)

Which produces this output:

>>> sort_by_last_letter(['ghi', 'def', 'abc'])
.last_letter at 0x7f276dd571e0>
['abc', 'def', 'ghi']
>>> sort_by_last_letter(['ghi', 'def', 'abc'])
.last_letter at 0x7f276dd57268>
['abc', 'def', 'ghi']
>>> sort_by_last_letter(['ghi', 'def', 'abc'])
.last_letter at 0x7f276dd572f0>
['abc', 'def', 'ghi']

On Fri, Mar 15, 2019 at 8:47 AM Arup Rakshit  wrote:

> Hi,
>
> I am reading a book where it says that:
>
> Just like module-level function definitions, the definition of a local
> function happens at run time when the def keyword is executed.
> Interestingly, this means that each call to sort_by_last_letter results in
> a new definition of the function last_letter. That is, just like any other
> name bound in a function body, last_letter is bound separately to a new
> function each time sort_by_last_letter is called.
>
> If that above is true, why the below program shows the same object
> reference for last_letter every time I call function sort_by_last_letter.
>
> # file name is sample.py
>
> def sort_by_last_letter(strings):
> def last_letter(s):
> return s[-1]
> print(last_letter)
> return sorted(strings, key=last_letter)
>
> python3 -i sample.py
> >>> sort_by_last_letter(['ghi', 'def', 'abc'])
> .last_letter at 0x1051e0730>
> ['abc', 'def', 'ghi']
> >>> sort_by_last_letter(['ghi', 'def', 'abc'])
> .last_letter at 0x1051e0730>
> ['abc', 'def', 'ghi']
> >>> sort_by_last_letter(['ghi', 'def', 'abckl'])
> .last_letter at 0x1051e0730>
> ['def', 'ghi', 'abckl']
> >>>
>
>
> Thanks,
>
> Arup Rakshit
> a...@zeit.io
>
>
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspea...@redhat.com  M: +1.336.210.5107
<https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Not Defined error in basic code

2019-03-14 Thread Calvin Spealman
You still need to get of the two lines at the start of your class, they are
unnecessary and reference variables you never defined:

class weapon:
weaponId  # Get rid of this line!
manufacturerName  # And this one, too!

On Thu, Mar 14, 2019 at 12:43 PM Jack Dangler  wrote:

>
> On 3/14/19 10:39 AM, Calvin Spealman wrote:
>
> A few notes, Jack:
>
> On Thu, Mar 14, 2019 at 10:32 AM Jack Dangler  wrote:
>
>>
>> On 3/14/19 10:11 AM, Calvin Spealman wrote:
>>
>> Where are you seeing something like this? The two lines under `class
>> weapon:` are not correct because they are variable names that you've never
>> defined.
>>
>> Maybe you intended this to "declare" the attributes for the class? That
>> isn't something you need to do in Python. If you simply remove these lines
>> your example should work.
>>
>> On Thu, Mar 14, 2019 at 10:05 AM Jack Dangler  wrote:
>>
>>> Just getting started with tutorials and such, and don't understand this -
>>>
>>> 
>>>
>>> class weapon:
>>>  weaponId
>>>  manufacturerName
>>>
>>>  def printWeaponInfo(self):
>>>  infoString = "ID: %d Mfg: %s Model: %s" % (self.weaponId,
>>> self.manufacturerName)
>>>  return infoString
>>>
>>> 
>>>
>>> import class_weapon
>>>
>>> MyWeapon=weapon()
>>> MyWeapon.weaponId = 100
>>> MyWeapon.manufacturerName = "Glock"
>>>
>>> print(MyWeapon.printWeaponInfo)
>>>
>>> executing 'python3 weaponTrack.py' results in this bailing on the first
>>> element in the class with "not defined". I've been staring at templates
>>> of this exact structure for about an hour trying to figure out why this
>>> isn't running at all. Is it simply because it isn't all in one file?
>>> Thanks for any guidance. Really appreciate the help.
>>>
>>>
>>> Thanks.
>>>
>>> --
>>> https://mail.python.org/mailman/listinfo/python-list
>>>
>>
>>
>> --
>>
>> CALVIN SPEALMAN
>>
>> SENIOR QUALITY ENGINEER
>>
>> cspea...@redhat.com  M: +1.336.210.5107
>> <https://red.ht/sig>
>> TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
>>
>> Calvin
>>
>> Thank you for the reply. I tried defining them in the form of 'int
>> weaponId' but that didn't help. I finally put it in this form 'weaponId=0"
>> and it liked that. So, i updated the class file to be as follows -
>>
>> 
>>
>> class weapon:
>>  weaponId=0
>>  manufacturerName=""
>>
> Technically this will work, but it won't always work. You're assigning
> these values directly to the class (or type) and not to individual objects
> of that type.
>
> This will break very badly if you try to do this with any type of value
> that can be changed (like a list, which you can add things to) because
> you'll accidentally
> modify values shared between ALL objects of the same type. Instead, you
> want to define a __init__ method, which is called when all objects of this
> type are
> created, and assign the attributes in there. Like this:
>
> def __init__(self):
> self.weaponId = 0
> self.manufacturerName = ""
>
> Of course, you could make it easier to create the specific objects you
> want by passing parameters at the creation of the object:
>
> def __init__(self, weaponId, manufacturerName):
> self.weaponId = weaponId
> self.manufacturerName = manufacturerName
>
>  def printWeaponInfo(self):
>>  infoString = "ID: %d Mfg: %s " % (self.weaponId,
>> self.manufacturerName)
>>  return infoString
>>
>> The second file now looks like this -
>>
>> 
>>
>> import class_weapon
>> MyWeapon=class_weapon.weapon
>> MyWeapon.weaponId = 100
>> MyWeapon.manufacturerName = "Glock"
>>
> If you follow my advice above, you won't need to override the values here.
>
> But you aren't actually creating anything here, because this line:
>
> MyWeapon = class_weapon.weapon
>
> Doesn't create anything. It just assigns the class you made to a new name.
> What you probably meant to do, and can do with the
> __init__ I suggest above, is create an instance of your weapon class like
> this:
>
> MyWeapon = class_weapon.weapon(100, "Glock")
>
>>
>> print(MyWeapon.printWeaponInfo)
>>
> Similarly, you probably meant to call this method but without parenthe

Re: Not Defined error in basic code

2019-03-14 Thread Calvin Spealman
A few notes, Jack:

On Thu, Mar 14, 2019 at 10:32 AM Jack Dangler  wrote:

>
> On 3/14/19 10:11 AM, Calvin Spealman wrote:
>
> Where are you seeing something like this? The two lines under `class
> weapon:` are not correct because they are variable names that you've never
> defined.
>
> Maybe you intended this to "declare" the attributes for the class? That
> isn't something you need to do in Python. If you simply remove these lines
> your example should work.
>
> On Thu, Mar 14, 2019 at 10:05 AM Jack Dangler  wrote:
>
>> Just getting started with tutorials and such, and don't understand this -
>>
>> 
>>
>> class weapon:
>>  weaponId
>>  manufacturerName
>>
>>  def printWeaponInfo(self):
>>  infoString = "ID: %d Mfg: %s Model: %s" % (self.weaponId,
>> self.manufacturerName)
>>  return infoString
>>
>> 
>>
>> import class_weapon
>>
>> MyWeapon=weapon()
>> MyWeapon.weaponId = 100
>> MyWeapon.manufacturerName = "Glock"
>>
>> print(MyWeapon.printWeaponInfo)
>>
>> executing 'python3 weaponTrack.py' results in this bailing on the first
>> element in the class with "not defined". I've been staring at templates
>> of this exact structure for about an hour trying to figure out why this
>> isn't running at all. Is it simply because it isn't all in one file?
>> Thanks for any guidance. Really appreciate the help.
>>
>>
>> Thanks.
>>
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>
>
> --
>
> CALVIN SPEALMAN
>
> SENIOR QUALITY ENGINEER
>
> cspea...@redhat.com  M: +1.336.210.5107
> <https://red.ht/sig>
> TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
>
> Calvin
>
> Thank you for the reply. I tried defining them in the form of 'int
> weaponId' but that didn't help. I finally put it in this form 'weaponId=0"
> and it liked that. So, i updated the class file to be as follows -
>
> 
>
> class weapon:
>  weaponId=0
>  manufacturerName=""
>
Technically this will work, but it won't always work. You're assigning
these values directly to the class (or type) and not to individual objects
of that type.

This will break very badly if you try to do this with any type of value
that can be changed (like a list, which you can add things to) because
you'll accidentally
modify values shared between ALL objects of the same type. Instead, you
want to define a __init__ method, which is called when all objects of this
type are
created, and assign the attributes in there. Like this:

def __init__(self):
self.weaponId = 0
self.manufacturerName = ""

Of course, you could make it easier to create the specific objects you want
by passing parameters at the creation of the object:

def __init__(self, weaponId, manufacturerName):
self.weaponId = weaponId
self.manufacturerName = manufacturerName

 def printWeaponInfo(self):
>  infoString = "ID: %d Mfg: %s " % (self.weaponId,
> self.manufacturerName)
>  return infoString
>
> The second file now looks like this -
>
> 
>
> import class_weapon
> MyWeapon=class_weapon.weapon
> MyWeapon.weaponId = 100
> MyWeapon.manufacturerName = "Glock"
>
If you follow my advice above, you won't need to override the values here.

But you aren't actually creating anything here, because this line:

MyWeapon = class_weapon.weapon

Doesn't create anything. It just assigns the class you made to a new name.
What you probably meant to do, and can do with the
__init__ I suggest above, is create an instance of your weapon class like
this:

MyWeapon = class_weapon.weapon(100, "Glock")

>
> print(MyWeapon.printWeaponInfo)
>
Similarly, you probably meant to call this method but without parenthesis
on the method you just printed the object representing
the method itself, rather than calling it and printing the value it returns.

print(MyWeapon.printWeaponInfo())

> so now, when I run 'python3 weaponTrack.py', I get  weapon.printWeaponInfo at 0x7f2bd3ae7510>, but am expecting
>
> ID: 100 Mfg: Glock ...
>
I hope this helps.

-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspea...@redhat.com  M: +1.336.210.5107
<https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Not Defined error in basic code

2019-03-14 Thread Calvin Spealman
Where are you seeing something like this? The two lines under `class
weapon:` are not correct because they are variable names that you've never
defined.

Maybe you intended this to "declare" the attributes for the class? That
isn't something you need to do in Python. If you simply remove these lines
your example should work.

On Thu, Mar 14, 2019 at 10:05 AM Jack Dangler  wrote:

> Just getting started with tutorials and such, and don't understand this -
>
> 
>
> class weapon:
>  weaponId
>  manufacturerName
>
>  def printWeaponInfo(self):
>  infoString = "ID: %d Mfg: %s Model: %s" % (self.weaponId,
> self.manufacturerName)
>  return infoString
>
> 
>
> import class_weapon
>
> MyWeapon=weapon()
> MyWeapon.weaponId = 100
> MyWeapon.manufacturerName = "Glock"
>
> print(MyWeapon.printWeaponInfo)
>
> executing 'python3 weaponTrack.py' results in this bailing on the first
> element in the class with "not defined". I've been staring at templates
> of this exact structure for about an hour trying to figure out why this
> isn't running at all. Is it simply because it isn't all in one file?
> Thanks for any guidance. Really appreciate the help.
>
>
> Thanks.
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspea...@redhat.com  M: +1.336.210.5107
<https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Class Issue`

2019-03-06 Thread Calvin Spealman
> C++ (a language I have no respect for)

This was uncalled for and inappropriate. Please keep discord civil.

On Wed, Mar 6, 2019 at 7:12 AM Rhodri James  wrote:

> On 05/03/2019 22:39, Milt wrote:
> > The following code gives me unusual results - base on experience with
> C++.
> >
> > class Car:
> > # carColor = None
> > # mileage = None
> >
> > def __init__(self, color = None, miles = None):
> >self.mileage = miles
> >self.carColor = color
> >
> > def print(self):
> >print(f"Color:   {self.carColor}")
> >print(f"Mileage: {self.mileage}")
> >
> > myCar = Car('blue', 15000)
> > myCar.print()
> >
> > print()
> >
> > myCar = Car(25000, 'orange')
> > myCar.print()
>
> The behaviour you should expect even from C++ (a language I have no
> respect for) is a compile-time error complaining that you are passing an
> integer to a string parameter and vice versa.  Python is a dynamically
> typed language; it doesn't enforce any restrictions on what types of
> object can be bound to any given name.  This is occasionally a surprise
> when you're being careless, but it really shouldn't break your
> expectations.
>
> --
> Rhodri James *-* Kynesim Ltd
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspea...@redhat.com  M: +1.336.210.5107
<https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: missing 1 required positional argument error

2019-02-26 Thread Calvin Spealman
you call it by visiting the route you've mapped to it, so when you run this
app and navigate to the root / URL it gets called. What do you expect this
parameter to be and where did you expect it to come from when you wrote the
listall() function?

On Tue, Feb 26, 2019 at 10:15 AM  wrote:

> I'm receiving the following error:
>
> Traceback (most recent call last):
>   File "/usr/lib64/python3.6/site-packages/bottle.py", line 862, in _handle
> return route.call(**args)
>   File "/usr/lib64/python3.6/site-packages/bottle.py", line 1740, in
> wrapper
> rv = callback(*a, **ka)
>   File "/usr/lib64/python3.6/site-packages/bottle.py", line 2690, in
> wrapper
> return func(*a, **ka)
> TypeError: listall() missing 1 required positional argument: 'pymydb'
>
> and this is my route definition:
>
> @app.route( '/' )
> @auth_basic(counters.is_authenticated_user)
> def listall( pymydb ):
>
> The way i understand this error is that i'am trying to call 'listall()'
> without giving it an argument while in its definition i do have 'pymydb' as
> a parameter.
>
> BUT from inside my script i do NOT call listall at all, so how can it miss
> an argument?
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspea...@redhat.com  M: +1.336.210.5107
<https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Unable to Install Python 3.7.2 64 bit version on my Windows 8.1

2019-02-20 Thread Calvin Spealman
In what way is it "unable to open the ride.py" file? Can you give details
about how you're trying to open or run that, what you expect to happen, and
what's happening instead?

On Wed, Feb 20, 2019 at 8:22 AM Subash Netha  wrote:

> Hello Team,
>
> I'm trying to install Python 3.7.2  64 bit version on my Windows 8.1
> Operating system with Robot framework ride with Selenium Libraries.
>
> However, Python is getting installed in local drive installed of C drive
> and unable to open the ride.py.
>
> Please let me know, if there is work around for the same or any
> documentation would be greatly appreciated.
>
> Hoping to hear from you soon.
>
> Thanks,
> Subash
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspea...@redhat.com  M: +1.336.210.5107
<https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pip not working

2019-02-20 Thread Calvin Spealman
Can you give any more information than that?

On Wed, Feb 20, 2019 at 8:30 AM prasis poudel  wrote:

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


-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspea...@redhat.com  M: +1.336.210.5107
<https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: not installing properly

2019-02-20 Thread Calvin Spealman
What EXE file have you downloaded? How are you trying to run it? What are
you expecting it to do and what is it doing instead?

You'll need to provide more information in order to help us help you.

On Wed, Feb 20, 2019 at 8:26 AM Vandna Mahendroo 
wrote:

>  Dear ...
>
> I am trying to instaal python but not working properly.
>
> i have downloaded on exe file ..but it is not starting
>
> please help me..
>
>
>
>
>
> --
> Regards:
>
> Vandna mahendroo
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspea...@redhat.com  M: +1.336.210.5107
<https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: f-string not referenced in library

2019-02-20 Thread Calvin Spealman
The string library is a utility set of functions with common string
operations and that documentation is about the specific library, not the
concept of strings or their syntax and other features in the language
itself. For more about f-strings and other string behaviors, read the
documentation on strings, the type, and other literals here
https://docs.python.org/3.7/reference/lexical_analysis.html#literals

That said, I do think you make a good point about the discovery of
documentation. If a reader would reasonably find themselves in the wrong
location while looking for information, maybe more can be done to guide
them to the right place.

On Wed, Feb 20, 2019 at 8:34 AM Caridad Díaz Rivero <
caridad.diaz.riv...@gmail.com> wrote:

> Hi,
> I don´t have too much experience using the official python documentation,
> and I was looking about f-string and I didn´t find anythings in
> /3/library/string.html <https://docs.python.org/3/library/string.html>
> and
> I find it in  3/reference/lexical_analysis.html#f-strings
> <https://docs.python.org/3/reference/lexical_analysis.html#f-strings> and
> I
> didn´t now Why it is not referenced in the documentation of String Library?
> Regards,
> Caridad Díaz
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspea...@redhat.com  M: +1.336.210.5107
<https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Convert a list with wrong encoding to utf8

2019-02-14 Thread Calvin Spealman
If you see something like this

'\xce\x86\xce\xba\xce\xb7\xcf\x82
\xce\xa4\xcf\x83\xce\xb9\xce\xac\xce\xbc\xce\xb7\xcf\x82'

then you don't have a string, you have raw bytes. You don't "encode" bytes,
you decode them. If you know this is already encoded as UTF-8 then you just
need the decode('utf8') part and *not* the encode('latin1') step.

encode() is something that turns text into bytes
decode() is something that turns bytes into text

So, if you already have bytes and you need text, you should only want to be
doing a decode() and you just need to specific the correct encoding.

On Thu, Feb 14, 2019 at 12:15 PM  wrote:

> Τη Πέμπτη, 14 Φεβρουαρίου 2019 - 6:45:29 μ.μ. UTC+2, ο χρήστης Calvin
> Spealman έγραψε:
> > You can only decode FROM the same encoding you've encoded TO. Any
> decoding
> > must know the input it receives follows the rules of its encoding scheme.
> > latin1 is not utf8.
> >
> > However, in your case, you aren't seeing problem with  the decoding. That
> > step is never reached. It is failing to encode the string as latin1
> because
> > it is not compatible with the latin1 scheme. Your string contains
> > characters which cannot be represented in latin1.
> >
> > It really is not clear what you're trying to accomplish here. The string
> > encoding was already handled when you pulled this out of the database and
> > you should not need to do anything like this at all. You already have a
> > decoded string, because in python ALL strings are decoded already.
> Encoding
> > is only a process of converting strings to raw bytes for storage or
> > transmission, which you don't appear to be doing here.
>
> Names in database are stored in utf8
> When the script runs it reads them and handles them as utf8, right?
>
> If it like this, then why when i print 'names' list i see bytes in
> hexadecimal format?
>
> '\xce\x86\xce\xba\xce\xb7\xcf\x82
> \xce\xa4\xcf\x83\xce\xb9\xce\xac\xce\xbc\xce\xb7\xcf\x82'
>
> And only if i
>
> for name in names:
> print( name.encode('latin1').decode('utf8') )
>
> i can see the values of 'name' list correctly in Greek.
>
> But where did the latin-iso took in place? And aparrt for printing the
> name like above how can i store them in proper utf ?
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspea...@redhat.com  M: +1.336.210.5107
<https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Convert a list with wrong encoding to utf8

2019-02-14 Thread Calvin Spealman
You can only decode FROM the same encoding you've encoded TO. Any decoding
must know the input it receives follows the rules of its encoding scheme.
latin1 is not utf8.

However, in your case, you aren't seeing problem with  the decoding. That
step is never reached. It is failing to encode the string as latin1 because
it is not compatible with the latin1 scheme. Your string contains
characters which cannot be represented in latin1.

It really is not clear what you're trying to accomplish here. The string
encoding was already handled when you pulled this out of the database and
you should not need to do anything like this at all. You already have a
decoded string, because in python ALL strings are decoded already. Encoding
is only a process of converting strings to raw bytes for storage or
transmission, which you don't appear to be doing here.

On Thu, Feb 14, 2019 at 11:40 AM  wrote:

> Hello, i have tried the following to chnage encoding to utf8 because for
> some reason it has changed regarding list names
>
> [python]
> #populate client listing into list
> names.append( name )
> 
> 
> names.append( '' )
> names.sort()
>
> for name in names:
> name = name.encode('latin1').decode('utf8')
> [/python]
>
> and the error that was presented was:
>
> [output]
> UnicodeEncodeError('latin-1', 'Άκης Τσιάμης', 0, 4, 'ordinal not in
> range(256)')
> [/output]
>
> Why it cannot encode in latin nad decode in utf8 normally?
> And since 'names' are being fetced from mysql database, which they were
> stored as utf8 strings WHY/HOW the 'names' enrolled in latin-1?
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspea...@redhat.com  M: +1.336.210.5107
<https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: System printer object

2019-01-07 Thread Calvin Spealman
Neither Python nor Tkinter include interface libraries to talk to hardware
printers out of the box, but a number of libraries and methods exist
depending on your platform. Both Wx and Qt, UI toolkits with great Python
bindings, do support printers to one degree or another, although I don't
know how difficult these are to work with. Either may offer good options,
or at least a starting point, if you look at the wxPython and/or PyQt
libraries.

On Mon, Jan 7, 2019 at 5:20 PM Dave  wrote:

> I need to print to one or both of my system printers.  I have not found
> a printer object in Python or in Tkinter.  This needs to work with
> Linux, Window, and Mac.  Can someone point me in the right direction?
> Ultimately, I want to have a File/Print in the menu that lets me select
> the printer and properties.
>
> Thanks,
> Dave
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspea...@redhat.com  M: +1.336.210.5107
<https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: pickle and module versioning

2018-12-17 Thread Calvin Spealman
This can definitely be a problem, but there are tried and true strategies to 
deal with it and the best course of action depends a lot on what works for you. 
Pickle deserialization is just an API instantiating your class instances. That 
means all the same rules and approaches to API changes apply like any other 
code changes.

So, if you have to add a field to a class it’ll need to be optional, so 
previous callers to that API can still use it and the same rule exists here. If 
you add a new field and its optional or has a default, then un-pickling from an 
older version should still work if those original fields are still valid.

It does mean the changes you can make are limited, so you need to think through 
the implications. One approach to mitigating that problem is to isolate the 
serializing to data classes intended specifically for pickling, so larger 
changes can happen outside those classes.


From: Neal Becker
Sent: Monday, December 17, 2018 7:02 AM
To: python-list@python.org
Subject: pickle and module versioning

I find pickle really handy for saving results from my (simulation) 
experiments.  But recently I realized there is an issue.  Reading the saved 
results requires loading the pickle, which in turn will load any referenced 
modules.  Problem is, what if the modules have changed?

For example, I just re-implemented a python module in C++, in a not quite 
compatible way.  AFAIK, my only choice to not break my setup is to choose a 
different name for the new module.

Has anyone else run into this issue and have any ideas?  I can imagine 
perhaps some kind of module versioning could be used (although haven't 
really thought through the details).

Thanks,
Neal

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

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


Re: question on the 'calendar' function

2018-11-21 Thread Calvin Spealman
Sorry, but, that is largely what programming is.

On Wed, Nov 21, 2018 at 4:09 PM o1bigtenor  wrote:

> On Wed, Nov 21, 2018 at 2:47 PM Calvin Spealman 
> wrote:
> >
> > Python and the standard library are all tools, but you still need to use
> those tools to accomplish something.
> >
>
> This is am understanding.
> What I'm doing is making tools to make tools to make tools to make
> tools to make decisions
> and I'm finding that a very large amount of my time is spent making tools.
> Wanted to curtail that time amount but not having much luck!
>
> Regards
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: question on the 'calendar' function

2018-11-21 Thread Calvin Spealman
Python and the standard library are all tools, but you still need to *use*
those tools to accomplish something.

On Wed, Nov 21, 2018 at 12:01 PM o1bigtenor  wrote:

> On Wed, Nov 21, 2018 at 8:09 AM Calvin Spealman 
> wrote:
> >
> > You really have the pieces you need here. You can print a whole year's
> calendar with calendar.formatyear() or a single month with
> calendar.monthcalendar(). If you need multiple years, call the first more
> than once with each year you need to print. If you need partial years,
> print the individual months you need with monthcalendar()
> >
> > Can you actually be more specific on what about the task is stumping you?
>
> OK so there needs to be a 2 level request, as I'm thinking of it,
> rather than being able to
> write something like (using human speak):
>
> print 36 months starting from 2017.06  or
> print 60 months starting from 2017.03 with possible formatting
> instructions.
>
> There seem to be a severe limit in the function in that a year is a
> maximum single
> time frame. I need to function within a time range of 2 to 3 or 4
> years. That means
> that I move between the week/month and the longer frame lots and most
> software
> seems to be hard limited to a single year as the limit on the macro scale.
>
> Oh well - - - - guess I can't do what I want then - - - thanks for the
> assistance.
>
> Regards
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Need help for python on my pc.

2018-11-21 Thread Calvin Spealman
Hi, I'm afraid attachments are stripped out of e-mails sent to this list.
Anything you sent was not included, so you'll need to share them in some
other way if you'd like to ask for help.

On Wed, Nov 21, 2018 at 1:18 PM Sourav Banik  wrote:

> Hello Python team,
> I'm using python 3.7(32 bit) for several months on my same laptop (x64
> processor). I worked on some django project very swiftly without any
> problem. But for a few days I am facing a serious problem. My python files
> are not showing properly by the file manager. It is just showing 'python
> source file' without any logo. When I open my cmd to work on django, it is
> not also working though virtualenv is working properly I think. I'm sending
> some screenshots of cmd and files for your reference.
> I've tried reinstalling (64 bit) and repairing of python but nothing is
> working. I want your help to sort out this issue.
> From
> Sourav Banik,
> Dhaka,Bangladesh.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Question about implementing immutability

2018-11-21 Thread Calvin Spealman
If you want to create your own immutable class, maybe inherit from a
namedtuple?

On Wed, Nov 21, 2018 at 11:45 AM Iwo Herka  wrote:

> Hello,
>
> Let's say I want to implement immutability for user-defined class.
> More precisely, a class that can be modified only in its (or its
> super-class') __init__ method. My initial idea was to do it the
> following fashion:
>
> def __setattr__(self, *args, **kwargs):
> if sys._getframe(1).f_code.co_name == '__init__':
> return super().__setattr__(*args, **kwargs)
> raise AttributeError()
>
> What do you think of this approach? Is there a better one?
> Thanks.
>
> Sincerely,
> Iwo Herka
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: question on the 'calendar' function

2018-11-21 Thread Calvin Spealman
You really have the pieces you need here. You can print a whole year's
calendar with calendar.formatyear() or a single month with
calendar.monthcalendar(). If you need multiple years, call the first more
than once with each year you need to print. If you need partial years,
print the individual months you need with monthcalendar()

Can you actually be more specific on what about the task is stumping you?

On Wed, Nov 21, 2018 at 7:28 AM o1bigtenor  wrote:

> On Wed, Nov 21, 2018 at 2:37 AM  wrote:
> >
> > On Tuesday, November 20, 2018 at 7:53:06 PM UTC+1, o1bigtenor wrote:
> > > On Tue, Nov 20, 2018 at 11:50 AM Schachner, Joseph
> > >  wrote:
> > > >
> > > > It's possible I don't understand the question.  The calendar
> functions are NOT limited to this year or any limited range.
> > > >
> > > > Example:
> > > > import calendar
> > > > print( calendar.monthcalendar(2022, 12) )
> > > >
> > > > Prints lists of dates in each week of December 2022.  It prints:
> > > > [[0, 0, 0, 1, 2, 3, 4], [5, 6, 7, 8, 9, 10, 11], [12, 13, 14, 15,
> 16, 17, 18], [19, 20, 21, 22, 23, 24, 25], [26, 27, 28, 29, 30, 31, 0]]
> > > >
> > > > So, Dec 1 is a Wednesday; Dec 31 is a Saturday.
> > > >
> > > > That's 49 months ahead of this month.   Change the year and month to
> any (valid) number, and it will do what it does.
> > > > The only caveat is that if the moon's orbit slows down as it gets
> farther away from the earth and the earth's rotation speed changes, then
> the calculations done by calendar for leap years may not be correct about
> the distant future.
> > > >
> > >
> > > Greetings
> > >
> > > If my syntax or commands are wrong - - - - I've just started so
> > > something is likely to NOT be correct - - - grin - - - I'sa noob!
> > >
> > > # calendar 2019
> > >
> > > that is to show the year 2019
> > >
> > > How could I show June 2018 to Dec 2019, inclusive?
> > > Or June 2018 to Dec 2021, inclusive?
> > > Or June 2018 to Dec 2023 by week (June wk 1,2,3,4 2018; July wk
> > > 1,2,3,4,5 2018; . . .   Dec wk 1,2,3,4,5 2023 or maybe even by dates),
> > > inclusive?
> > >
> > > Note that the time frame is ALWAYS more than 1 year.
> > > AIUI there isn't a way to do that, at least not that I can see, and I
> > > would like to be able to do that.
> > > A friend suggested using a script wrapped around the command. I
> > > thought maybe there might we a way of doing what I need to do without
> > > using 2 levels of programming.
> > >
> > > Regards
> >
> > From what you post it seems like you are on a Linux kind of system and
> you are running the `calendar` command in the bash terminal. If that is
> correct, try the following:
> >
> > In the bash terminal type (without the literal #):
> > # python
> >
> > This will put you in the Python prompt (marked with >>>).
> > Check that the first line starts with Python 3. If not, I highly
> recommend
> > you install Python 3. If it is Python two, the following will work, but
> you
> > have to drop the outer parentheses for print (thus print
> calendar.calendar())
> >
> > Then type the following:
> > >>> import calendar
> > >>> print(calendar.calendar(2020))
>
> > Now look at the documentation of the calendar module to find out about
> > other options.
> >
>
> Thank you very much Mr Marco - - - that got me to being able to do
> something
> (will need time to figure out how to do the rest! grin!!).
> I have read through the documentation and there really doesn't seem to be
> a way
> to do what I would like to do - - - - in this case.
>
> What I can't do is (following your directions)
>
> >>> import calendar
> >>> print(calendar.calendar(Mar 2018 to Dec 2023))
>
> What I need is to be able to have more than one calendar year options and
> this
> function seems to be limited to work with a maximum of only one year at a
> time.
>
> If I not reading the documentation correctly - - - please advise.
> (Thanking you for your generous assistance in the foregoing!)
>
> Regards
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: recommends of redesign OO feature of python !!!

2018-10-25 Thread Calvin Spealman
It does not appear that you actually want to use Python.

On Thu, Oct 25, 2018 at 1:15 AM iamybj--- via Python-list <
python-list@python.org> wrote:

> I am an engineer of java and c#, I want to some personal projects in free
> time, and I choose python.
>
> After try python, I hava some suggestion.
>
> The first thing is that python’s class is not well designed than other
> programming languages.
> Using dictionary as data model is the 20th century style, but now is 21t
> century.We usually use strong typed class to express a data model.
> For example,  the code presentation of a person in Java/c++/c# may be:
> public class Person {
> public String name;
> public String email;
> public int age;
> }
> The corresponding Python code:
> class Person:
> def __init__(self):
> self.name = None
> self.email = None
> self.gage = None
> It is very strange to define instance members of a class in
> constructor.Even the OOP feature of PHP is very like Java. Python's dynamic
> feature has lost control.
>
> Second, python is too complex.
> Python is an old programming language.At that time, enterprise programming
> style is very popular, witch like making simple things become complex, so
> force the costumer to pay more money.But now is WWW and Internet and Linux
> time, people like simple production and simple programming styles. Every
> new programming language wants to keep simple.
>
> Third, python is too slow.
> At the old enterprise programming time, performance is not a critical
> feature. If software runs too slow, customer have  to pay more money to
> enterprise software company to buy new hardware.
> Time changed, performance is very important now. Because the complex of
> python, the pypy project process very slow, and not widely used by people.
>
> Totally speaking, simple and performance are mostly required by this
> times. I suggest the python team should stop any new work, and start to
> rebuild a new python with simple grammar and better performance.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: I am not able to run Python in Powershell

2018-09-29 Thread Calvin Spealman
Did you actually confirm the PATH variable contains the right path?

echo $env:Path

And look for a path entry that mentions Python. Then, make sure you can
actually find python.exe in that location.

As long as you keep the PATH option checked with the Python installer it
absolutely should work from PowerShell. What version of Python did you
install? Have you also tried to invoke Python from the Command Prompt to
determine if the issue only affects PowerShell or not?

On Fri, Sep 28, 2018 at 1:10 PM  wrote:

> On Friday, 1 September 2017 19:37:41 UTC+1, The Cat Gamer  wrote:
> > fter I installed Python I try to open it in Powershell, by typing
> > python/python.exe.
> > It gives me an error:
> > python : The term 'python' is not recognized as the name of a cmdlet,
> > function, script file, or operable program. Check the spelling of the
> name,
> > or if a path was included, verify that the path is correct and try again.
> > At line:1 char:1
> > + python
> > + ~~
> > + CategoryInfo  : ObjectNotFound: (python:String) [],
> > CommandNotFoundException
> > + FullyQualifiedErrorId : CommandNotFoundException
> > This happens with version 3 and version 2. The newest versions and the
> > older versions none of them makes me able to open Python in Windows
> > Powershell. Are you guys aware of a fix?
> >
> > (I already tried the environment fix and that didnt work as well)
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [OT] master/slave debate in Python

2018-09-25 Thread Calvin Spealman
This entire conversation is inappropriate for this mailing list. Please
leave this free for people who need to ask and give help with Python,
regardless of which side of this argument you are on.

On Tue, Sep 25, 2018 at 4:44 AM Robin Becker  wrote:

> On 24/09/2018 21:40, Kirill Balunov wrote:
> ...
> > It seems to me that the word "black" has immunity in the next two Python
> > releases ;)  So do not worry so much!
> >
> apparently whitelist/blacklist is an issue so presumably white should also
> get immunity :)
>
> > But honestly, it's not pleasant to see how such holy things spread into
> the
> > world of OSS, and this is apparently only the beginning.
> +1
> --
> Robin Becker
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Hi I'm trying to get live data from stock using python , is it poss

2018-09-05 Thread Calvin Spealman
Please don't keep spamming this list with the same question, while you have
not responded to any of the advice you've already been given.

If you have specific trouble with any of that advice and need further help,
please give details and ask new questions!

Good luck.

On Wed, Sep 5, 2018 at 4:02 PM alon najman  wrote:

> On Tuesday, September 4, 2018 at 7:21:31 PM UTC+3, alon@gmail.com
> wrote:
> > Hi ,
> > for example:
> > I want to know if AAPL is more than value 300 and if it does I want it to
> send to me mail with gmail :) . thanks for the help..
>
> im using python 2.7
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: how to make super() work with externally defined methods in inheritance???

2018-08-15 Thread Calvin Spealman
You really can't, and shouldn't. The super() helper relies on information
that exists inside the class definition and which is not available simply
at runtime by virtue of being attached to the class.

Besides, modifying classes externally is generally considered a bad idea.
Maybe you could accomplish this with a subclass adding this method, instead.

On Wed, Aug 15, 2018 at 4:04 PM, Paint-It-Black via Python-list <
python-list@python.org> wrote:

> > # this prints for me when I run this in 3.6
>
> excuse me, that is an extraneous comment from a cut and paste, in fact the
> example never makes it to the prints, as shown in the transcript just below
> the source code
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python shuts down when I try to run a module

2018-07-23 Thread Calvin Spealman
This is an unfortunate property of running command line programs on
Windows. If you run the script directly (like by double clicking on it?)
the console window will close when the program is done, so you can't see
the final output.

To get around this you could run them in the IDLE editor, which comes with
Python 3.7 for Windows, or you could open a windows command prompt and run
your Python scripts from there.

On Mon, Jul 23, 2018 at 3:00 AM, Lyra  wrote:

> Hello,
> I’ve just started to learn Python coding, and downloaded version 3.7.0
> from the website.  I’ve written 5 or 6 small programs and saved them, but
> whenever I try to run them, Python doesn’t work right.  The user answers
> the first question and presses ENTER, but then the Python window just
> closes, disappears, and shuts down.  My programs are all written correctly,
> and work just like they’re supposed to, when I run them in the Shell window
> instead.  There are no error messages.
> I went into the original installation file of Python and clicked on
> “Repair”.  There was a progress bar, and it said “Repair completed”, but
> the problem still occurs.
> I don’t want to uninstall the whole thing and download a different version
> until after I hear from someone here who knows more about it than I do.
>
> Please respond soon.
>
> Thanks.
>
>
> Sent from Mail for Windows 10
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Cookies not showing up in environ

2018-07-20 Thread Calvin Spealman
You can read cookies from the request via the request.COOKIES dictionary.
See the documentation here:
https://docs.djangoproject.com/en/2.0/ref/request-response/#django.http.HttpRequest.COOKIES

You won't find them in an environment variable, which is shared
process-wide and across all requests, because they are bound to each
request. This is not a CGI script, so those HTTP_* environment variables
you seem to expect won't be here.

On Fri, Jul 20, 2018 at 3:39 PM, abc abc  wrote:

> I am trying the simplest of examples below to set and read a cookie. I am
> using the Django framework, but I have also tried with vanilla python
> cookies and os.environ. I have posted elsewhere, but this hasn't gotten
> much attention, so I'd really appreciate any help.
>
> Thinking at this point it may be something to with the server, not python.
> I have tried uwsgi/nginx, gunicorn/nginx, django development server with no
> success.
>
> view.py:
>
> def index(environ, start_response, request):
> if not 'HTTP_COOKIE' in environ:
> response = HttpResponse("hello")
> response.set_cookie('user_agreement', 'cookie text', domain='.
> mysite.com')
> return response
> else:
> print environ['HTTP_COOKIE']
>
> The webpage just prints 'hello' and never reaches the else not matter how
> many times I refresh the page. There are no cookies in the browser ever
> either.
>
> Am I missing some middleware? I remember some answers to cookie problems
> related to the order of their middleware configurations. Here's mine:
>
> MIDDLEWARE = [
> 'django.middleware.security.SecurityMiddleware',
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.middleware.common.CommonMiddleware',
> 'django.middleware.csrf.CsrfViewMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware',
> 'django.middleware.clickjacking.XFrameOptionsMiddleware',
> ]
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: about main()

2018-07-05 Thread Calvin Spealman
On Thu, Jul 5, 2018 at 1:41 PM, Jim Lee  wrote:

>
>
> On 07/05/18 10:15, Calvin Spealman wrote:
>
> On Thu, Jul 5, 2018 at 12:59 PM, Jim Lee  wrote:
>
>>
>>
>> On 07/05/18 05:14, Marko Rauhamaa wrote:
>>
>>> Abdur-Rahmaan Janhangeer :
>>>
>>>> * Create as many functions as you can
>>>>>
>>>> performance?
>>>>
>>> Python?
>>>
>>> Seriously, though. The principle of expressive encapsulation is one of
>>> the basic cornerstones of writing computer programs. Performance barely
>>> ever becomes a question, and even more rarely has anything to do with
>>> the number of function calls (low-level programming language compilers
>>> optimize efficiently).
>>>
>>> The most important objective of software development is the management
>>> of complexity. Silly performance optimizations are way down the priority
>>> list.
>>>
>>>
>>> Marko
>>>
>>
>> Sadly, this *is* the current mindset.
>>
>> "Don't bother optimizing, the compiler does it better than you can."
>>
>
> I think that is a pretty clear mis-characterization of what was said.
>
>
> Well, you did say "silly performance optimizations".
>

That wasn't me, but I do agree with the sentiment in that its often silly
to focus on them at the wrong time and without constraints that warrant
that focus.

> The mindset isn't that optimization will be done for you, but that it
> isn't high on a priority list.
>
>
> Things at the bottom of a priority list tend to never get done -
> especially in the current era of software development.  And if you rarely
> or never do something, you lose the skill.  The horde of programmers a
> generation or two from now may have no clue how to do these things.  That's
> the pitfall behind "smart tools".
>

You say "pitfall", but I say "allow developers to focus on higher-level
problems and enable developers to specialize among tasks so every single
one of us doesn't have to be a jack of all trades just to build a todo list
app".

¯\_(ツ)_/¯

> Tell me, who writes the compilers?  When we die off, nobody will have a
>> clue how to do it...
>>
>> -Jim
>>
>>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: about main()

2018-07-05 Thread Calvin Spealman
On Thu, Jul 5, 2018 at 12:59 PM, Jim Lee  wrote:

>
>
> On 07/05/18 05:14, Marko Rauhamaa wrote:
>
>> Abdur-Rahmaan Janhangeer :
>>
>>> * Create as many functions as you can

>>> performance?
>>>
>> Python?
>>
>> Seriously, though. The principle of expressive encapsulation is one of
>> the basic cornerstones of writing computer programs. Performance barely
>> ever becomes a question, and even more rarely has anything to do with
>> the number of function calls (low-level programming language compilers
>> optimize efficiently).
>>
>> The most important objective of software development is the management
>> of complexity. Silly performance optimizations are way down the priority
>> list.
>>
>>
>> Marko
>>
>
> Sadly, this *is* the current mindset.
>
> "Don't bother optimizing, the compiler does it better than you can."
>

I think that is a pretty clear mis-characterization of what was said.

The mindset isn't that optimization will be done for you, but that it isn't
high on a priority list. This is doubly true when looked at from a planning
perspective. Make something work first, make it organized and
understandable, and *then* and only if measurements warrant it do you need
to put resources explicitly towards performance.

Not because performance isn't important or that someone else will do it for
you, but because most problems and contexts do not have constraints that
warrant it as a high and immediate priority.

Tell me, who writes the compilers?  When we die off, nobody will have a
> clue how to do it...
>
> -Jim
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


ANN: Tracerlib 0.1 Released

2012-06-06 Thread Calvin Spealman
Tracerlib is a set of utilities to make tracing Python code easier.

It provides TracerManager, which can allow multiple trace functions to
coexist. It can easily be enabled and disabled, either manually or as
a context manager in a with statement.

Tracer classes make handling the different trace events much easier.

class TraceExceptions(Tracer):
def trace_exception(self, func_name, exctype, value, tb):
print Saw an exception: %r % (value,)

Tracer is also easily capable of filtering which events it listens to.
It accepts both an events parameter, a list of trace events it will
respond to, and a watch parameter, a list of paths it will respond to
in the form of package.module.class.function.

This can easily wrap a trace function, or you can subclass Tracer and
implement one of its helpful trace_*() methods.

And, a helper class FrameInspector which wraps a frame and makes it
trivial to inspect the function name and arguments the function had
been called with.

inspector = FrameInspector(sys._getframe())

print Called, inspector.func_name
print args:, inspector.args
print kwargs:, inspector.kwargs

You can read the full documentation at the read the docs site and see
the code at github.

http://tracerlib.readthedocs.org
https://github.com/ironfroggy/tracerlib
-- 
http://mail.python.org/mailman/listinfo/python-list


PyCarolinas 2012 Call For Proposals

2012-05-21 Thread Calvin Spealman
PyCarolinas 2012 Call For Proposals

PyCarolinas 2012, the first Python conference held in the carolinas,
is now accepting proposals! We’re looking for proposals for talks you
can present to this great and growing Python community.

PyCarolinas will be held in October in Chapel Hill, NC. The exact
location and dates of the two-day conference will be announced
shortly.

The proposal deadline is July 20, 2011. Please submit your proposals
to ta...@pycarolinas.org.
About PyCarolinas 2012

PyCarolinas 2012 is the first Python Conference held in the carolinas
and will be located in Chapel Hill, NC this October. The specific date
and location will be announced shortly. It is a two day conference,
with one day of talks and one day or sprinting.
Who should submit a proposal?

Anyone! We’re looking for as broad a cross-section of the Python
community as possible.

We’re looking for both experienced conference speakers and people new
to technical conferences; industry professionals and hobbyists;
entrepreneurs, researchers, and system administrators. You’ve probably
learned something that other Python users could benefit from, so come
toPyCarolinas and share your story. Maybe you’ve written the next
great data mining package, or you have a case study to share, or
you’ve learned something about how to start a Python users’ group, or
you just want to help novices learn how to choose a Python web
framework.

If you have something to tell your fellow Python programmers, this is
your chance.

You don’t have to be a professional speaker to give a talk at
PyCarolinas. Presenters can be volunteers from all walks of life and
all levels of experience. From hardcore hackers to educators to
hobbyists, anyone with something to say and the desire to say it is
welcome.

If you have a topic idea but you’re not sure exactly how to turn it
into a killer session, let us know! The program committee is happy to
work with you to help your session shine.
What kind of sessions can I give?

PyCarolinas 2012, as a small event, is acceptingonly traditional
sessions during the main conference. We are looking for sessions at 30
and 45 minutes. All levels of talks from from novice-level overviews
to advanced topics are welcome.
Conference registration and travel

PyCarolinas is entirely volunteer-organized and run, and must keep
costs as low as possible. We are unable to provide assistance or
compensation for speakers traveling to and staying near the conference
for the duration of the event.
Timeline and deadlines

Please don’t delay! The proposal window is long, but the sooner you
submit a proposal, the more time we’ll have to help you put forward
the best proposal. The program committee will officially begin
reviewing proposals and giving feedback as soon as the CFP closes, but
the team will attempt to begin reviewing and discussing proposals
prior to the close of the Call for Proposals to assist authors.

Proposals for talks will be accepted until July 20th. The list of
selected talks and tutorials will be finalized by the end of August.

Thank you!

Submit your proposal to ta...@pycarolinas.org and thanks for helping
us make the first ever PyCarolinas great!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PyCarolinas 2012 Call For Proposals

2012-05-21 Thread Calvin Spealman
CORRECTION

The proposal deadline is July 20, 2012

Not 2011, obviously.

On Mon, May 21, 2012 at 10:51 AM, Calvin Spealman ironfro...@gmail.com wrote:
 PyCarolinas 2012 Call For Proposals

 PyCarolinas 2012, the first Python conference held in the carolinas,
 is now accepting proposals! We’re looking for proposals for talks you
 can present to this great and growing Python community.

 PyCarolinas will be held in October in Chapel Hill, NC. The exact
 location and dates of the two-day conference will be announced
 shortly.

 The proposal deadline is July 20, 2011. Please submit your proposals
 to ta...@pycarolinas.org.
 About PyCarolinas 2012

 PyCarolinas 2012 is the first Python Conference held in the carolinas
 and will be located in Chapel Hill, NC this October. The specific date
 and location will be announced shortly. It is a two day conference,
 with one day of talks and one day or sprinting.
 Who should submit a proposal?

 Anyone! We’re looking for as broad a cross-section of the Python
 community as possible.

 We’re looking for both experienced conference speakers and people new
 to technical conferences; industry professionals and hobbyists;
 entrepreneurs, researchers, and system administrators. You’ve probably
 learned something that other Python users could benefit from, so come
 toPyCarolinas and share your story. Maybe you’ve written the next
 great data mining package, or you have a case study to share, or
 you’ve learned something about how to start a Python users’ group, or
 you just want to help novices learn how to choose a Python web
 framework.

 If you have something to tell your fellow Python programmers, this is
 your chance.

 You don’t have to be a professional speaker to give a talk at
 PyCarolinas. Presenters can be volunteers from all walks of life and
 all levels of experience. From hardcore hackers to educators to
 hobbyists, anyone with something to say and the desire to say it is
 welcome.

 If you have a topic idea but you’re not sure exactly how to turn it
 into a killer session, let us know! The program committee is happy to
 work with you to help your session shine.
 What kind of sessions can I give?

 PyCarolinas 2012, as a small event, is acceptingonly traditional
 sessions during the main conference. We are looking for sessions at 30
 and 45 minutes. All levels of talks from from novice-level overviews
 to advanced topics are welcome.
 Conference registration and travel

 PyCarolinas is entirely volunteer-organized and run, and must keep
 costs as low as possible. We are unable to provide assistance or
 compensation for speakers traveling to and staying near the conference
 for the duration of the event.
 Timeline and deadlines

 Please don’t delay! The proposal window is long, but the sooner you
 submit a proposal, the more time we’ll have to help you put forward
 the best proposal. The program committee will officially begin
 reviewing proposals and giving feedback as soon as the CFP closes, but
 the team will attempt to begin reviewing and discussing proposals
 prior to the close of the Call for Proposals to assist authors.

 Proposals for talks will be accepted until July 20th. The list of
 selected talks and tutorials will be finalized by the end of August.

 Thank you!

 Submit your proposal to ta...@pycarolinas.org and thanks for helping
 us make the first ever PyCarolinas great!



-- 
Read my blog! I depend on your acceptance of my opinion! I am interesting!
http://techblog.ironfroggy.com/
Follow me if you're into that sort of thing: http://www.twitter.com/ironfroggy
-- 
http://mail.python.org/mailman/listinfo/python-list


ANN: straight.command 0.1a1 - A command framework with a plugin architecture

2012-05-17 Thread Calvin Spealman
I'd like to announce a new project, based on straight.plugin, a
command framework that provides a declarative way to define
command-line options, sub-commands, and allows plugins from
third-parties to expand commands.

This is all very early, I'm calling this version 0.1a1 and lots of
things are missing, but here is an example (which works) of a small
todo application built with this.

#!/usr/bin/env python

from __future__ import print_function
import sys
from straight.command import Command, Option, SubCommand

class List(Command):
def run_default(self, **extra):
for line in open(self.parent.args['filename']):
print(line.strip('\n'))

class Add(Command):
new_todo = Option(dest='new_todo', action='append')

def run_default(self, new_todo, **extra):
with open(self.parent.args['filename'], 'a') as f:
for one_todo in new_todo:
print(one_todo.strip('\n'), file=f)

class Todo(Command):
filename = Option(dest='filename', action='store')

list = SubCommand('list', List)
add = SubCommand('add', Add)

if __name__ == '__main__':
Todo().run(sys.argv[1:])

And a sample of the result of this little script:

$ ./todo.py todo.txt add Write an example tool
$ ./todo.py todo.txt add Get the documentation cleaned up and on readthedocs
$ ./todo.py todo.txt add Blog about the project
$ ./todo.py todo.txt list
Write an example tool
Get the documentation cleaned up and on readthedocs
Blog about the project

The documentation and source are both available now.

docs: http://straightcommand.readthedocs.org/
source: https://github.com/ironfroggy/straight.command
announcement: 
http://techblog.ironfroggy.com/2012/05/ann-straightcommand-01a1-command.html

-- 
Read my blog! I depend on your acceptance of my opinion! I am interesting!
http://techblog.ironfroggy.com/
Follow me if you're into that sort of thing: http://www.twitter.com/ironfroggy
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: suppressing argparse arguments in the help

2012-02-28 Thread Calvin Spealman
On Tue, Feb 28, 2012 at 1:07 PM, Peter Otten __pete...@web.de wrote:
 Andrea Crotti wrote:

 On 02/28/2012 04:02 PM, Peter Otten wrote:
 Andrea Crotti wrote:

 I have a script that might be used interactively but also has some
 arguments that
 should not be used by normal users.
 So I just want to suppress them from the help.
 I've read somewhere that the help=SUPPRESS should do what I want:

       parser.add_argument('-n', '--test_only',
                           action='store_true',
                           help=SUPPRESS)

 but that's what I get from myapp -h, which is not exactly what I was
 looking for..


     -f, --first_level     ==SUPPRESS== (default: False)
     --never_redevelop     ==SUPPRESS== (default: False)


 Any other solutions?
 That shouldn't happen. Did you reload() somewhere?
 argparse tests object identity not equality with SUPPRESS, so you have to
 ensure that SUPPRESS stems from the same instance of the argparse module
 as your ArgumentParser.


 Ah great yes it wasn't actually the same..
 but why not just use
 if text != SUPPRESS
 instead of:
 if text is not SUPPRESS

Because identity tests are good in these situations where you need to pass a
special value and anything else could be valid, technically. This is known as
a sentinel and is a common pattern.

 Steven Bethard would have to answer that.
 If it were my code I would have used the equality test, but also the correct
 symbolic constant...

 probably the second is more safe, but they are it's still checking
 against a constant that
 is very unlikely to clash with anything..


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



-- 
Read my blog! I depend on your acceptance of my opinion! I am interesting!
http://techblog.ironfroggy.com/
Follow me if you're into that sort of thing: http://www.twitter.com/ironfroggy
-- 
http://mail.python.org/mailman/listinfo/python-list


Stand-Alone Python Executable Skeletons

2012-02-15 Thread Calvin Spealman
I've recently been looking into different options to package python
code into stand-alone executables, with tools like Py2EXE and
PyInstaller, but I'm left feeling a little lost. Documentation seems
sparse on all of them, the setups a little unusual to me. It feels
like they could be a lot simpler, or that I could put in some
preliminary work to make it easier for my needs in the long run. I'm
hoping someone can help me pick the best option.

What I would love to do (or know if it is possible) is have a set of
executables, for Linux, Windows, and OS X, with a Zip archive appended
to the end of them. I know the zip archive at the end of an executable
works with EXE and ELF binaries, but does it work for whatever OSX
uses (I have no mac machines, currently)? I'd like to build these
three empty stand-alone python executables, setup such that they'll
run any main.py sitting at the top level of the archive. After this,
building for all three platforms would just be a matter of copying the
empty versions and dumping the project into it.

I'm leaning on doing this with PyInstaller being the easiest. Am I
headed in the right direction? Ideally, these empty stand-alones could
be distributed for use by others without any tools required to use
them other than a zip utility.

-- 
Read my blog! I depend on your acceptance of my opinion! I am interesting!
http://techblog.ironfroggy.com/
Follow me if you're into that sort of thing: http://www.twitter.com/ironfroggy
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Please explain this for me

2011-12-20 Thread Calvin Spealman
On Dec 20, 2011 11:41 PM, Emeka emekami...@gmail.com wrote:


 Hello All,

 v = []

 def add_to_list(plist):
 u = plist.append(90)
 return u

 add_to_list(v)  # This function call returns nothing
 Could someone explain why this function call will return nothing?

 v = [90] # Object values are passed by reference
 This one is clear to me

 add_to_list([])
 This one returns nothing, why?

Because list.append() returns nothing, it only modifies the list in place.


 Regards,
 Emeka
 --
 Satajanus  Nig. Ltd




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

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


Re: How to get path to Python standard library directory?

2011-11-25 Thread Calvin Spealman
On Fri, Nov 25, 2011 at 6:24 AM, user user@nospam.invalid wrote:
 In a Makefile (or sometimes inside python) I need the path to the root of
 the Python standard lib folder used by env python.

 e.g.  /usr/lib/python2.6/   or    C:\Python27\Lib\

 what is the best/canonical way to get that?

This should get you what you're looking for. Just look relative to a
known stdlib module.

import os
stdlib_dir = os.path.dirname(os.__file__)

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




-- 
Read my blog! I depend on your acceptance of my opinion! I am interesting!
http://techblog.ironfroggy.com/
Follow me if you're into that sort of thing: http://www.twitter.com/ironfroggy
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: non-standard module location (again)

2011-10-21 Thread Calvin Spealman
I am biased, but you could use a plugin loader like straight.plugin at
https://github.com/ironfroggy/straight.plugin

On Fri, Oct 21, 2011 at 10:05 AM, Shane gshanemil...@verizon.net wrote:
 Need to refine a question I asked earlier. If I have a module,

 |--  foo
 |---|
 |---|---bar
 |---|---|
 |---|---|---__init__.py

 then I can say import foo.bar

 But suppose I want to import foo.bar.stuff and stuff isn't located on
 under `bar' because it's user
 supplied code:

 |- stuff                             - I want this to be logically
 under foo.bar
 |---|---__init__.py           - even though it's not under bar in
 the computer's file system

 Now what: how to arrange to do command: import foo.bar.stuff
 --
 http://mail.python.org/mailman/listinfo/python-list




-- 
Read my blog! I depend on your acceptance of my opinion! I am interesting!
http://techblog.ironfroggy.com/
Follow me if you're into that sort of thing: http://www.twitter.com/ironfroggy
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: syntax enhancement

2011-10-04 Thread Calvin Spealman
On Tue, Oct 4, 2011 at 9:50 AM, Valiev Sergey sval...@gmail.com wrote:

 Hi,
 you may found this idea stupid, but nevertheless...
 - `[]` - used for list comprehension,
 - `()` - used for generators,
 - `[start:stop]` / `[start:stop:step]` - used for slices.
 The idea is to use `(start:stop)` / `(start:stop:step)` as 'lazy evaluated'
 slices (like itertools.islice).
 What do you think about it?


It simply looks too much like a function call.


 --
 Best regards,
 Valiev Sergey
 *skype:* *svaliev*
 *jabber:* *sval...@gmail.com*
 *phone:* +7 926 233-17-64







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




-- 
Read my blog! I depend on your acceptance of my opinion! I am interesting!
http://techblog.ironfroggy.com/
Follow me if you're into that sort of thing:
http://www.twitter.com/ironfroggy
-- 
http://mail.python.org/mailman/listinfo/python-list


[issue12554] Failed imports clean up module, but not sub modules

2011-07-13 Thread Calvin Spealman

New submission from Calvin Spealman ironfro...@gmail.com:

I came across this behavior when it was related to the shadowing of a small 
typo bug and took me forever to find. In my case, the original error was 
shadowed in a way that is unrelated to this bug, but lead to the module being 
imported twice (because it was removed when it failed the first time) and then 
the second import caused a completely unexpected error, because the state of 
the submodules conflicted with the import-time logic of the top-level package.

I think when a module fails to load, all of its sub-modules should be removed 
from sys.modules, not just itself.

calvin@willow-delta:/tmp$ mkdir foo/
calvin@willow-delta:/tmp$ cat  foo/__init__.py
import foo.bar
1/0
calvin@willow-delta:/tmp$ cat  foo/bar.py
name = bar
calvin@willow-delta:/tmp$ python
Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53) 
[GCC 4.5.2] on linux2
Type help, copyright, credits or license for more information.
 import foo
Traceback (most recent call last):
  File stdin, line 1, in module
  File foo/__init__.py, line 2, in module
1/0
ZeroDivisionError: integer division or modulo by zero
 import sys
 sys.modules['foo.bar']
module 'foo.bar' from 'foo/bar.py'


--
components: Interpreter Core
messages: 140298
nosy: Calvin.Spealman
priority: normal
severity: normal
status: open
title: Failed imports clean up module, but not sub modules
type: behavior

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



Re: Project-wide variable...

2011-06-23 Thread Calvin Spealman
No, but you can define a name in one module and import that into others.

On Thu, Jun 23, 2011 at 9:41 AM, Gnarlodious gnarlodi...@gmail.com wrote:
 Is there a way to declare a project-wide variable and use that in all
 downstream modules?

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




-- 
Read my blog! I depend on your acceptance of my opinion! I am interesting!
http://techblog.ironfroggy.com/
Follow me if you're into that sort of thing: http://www.twitter.com/ironfroggy
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Function declarations ?

2011-06-08 Thread Calvin Spealman
Just write the function, at the top of the source. Easy peasy.

On Wed, Jun 8, 2011 at 9:58 AM, Andre Majorel che...@halliburton.com wrote:
 Is there a way to keep the definitions of the high-level
 functions at the top of the source ? I don't see a way to
 declare a function in Python.

 Thanks in advance.

 --
 André Majorel http://www.teaser.fr/~amajorel/
 J'ai des droits. Les autres ont des devoirs.
 --
 http://mail.python.org/mailman/listinfo/python-list




-- 
Read my blog! I depend on your acceptance of my opinion! I am interesting!
http://techblog.ironfroggy.com/
Follow me if you're into that sort of thing: http://www.twitter.com/ironfroggy
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Non Programming in python

2011-05-11 Thread Calvin Spealman
If this is the non-programming side of python then maybe some of us have a
lacking definition of what programming is.  My mechanic stilll has to
check the tire pressure and I need to update the version number in PyPI.

On May 10, 2011 12:46 PM, rusi rustompm...@gmail.com wrote:

Sorry for a silly subject change: A better one will be welcome -- cant
think of a name myself.

There is this whole area of python that may be called the non-
programming side of programming:

Is there some central site where all such is put up?
What if any should such a bundle of things be called?

-

 | Area | Tool(s)|
 |--+|
 | packaging| distutils, setuptools, |
 |  | distutils2, distribute |
 |  | Native tools (eg apt)  |
 | versioning   | hg, git, bzr   |
 | multiple pythons | virtualenv |
 | ??   | tox|
 | testing  | unittest, nose, pytest |
 | build| scons, make... |
 | deployment   | fabric |

--
* Primary Development tools/aids

 1. Help
 2. Completion ('intellisense')
 3. Tags (Jumping)
 4. Refactoring
 5. Integration with 'non-programming' above (eg VCSes, packagers
etc)

* Other Development Tools
 - Debugger
 - Profiler
 - Heap Profiler
 - Coverage
--
http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: who moved reload?

2011-04-19 Thread Calvin Spealman
I have a great solution : stop using reload. It often dangerous and more
often silly.

On Apr 7, 2011 5:44 AM, harrismh777 harrismh...@charter.net wrote:

All right...  somebody is sacked (er, fired) !

Who moved reload()?

This kinda stuff is driving me bonkers... there was no need to move reload()
anyplace...

... so for those of you who haven't found out yet, if you want to reload a
module in 3.x you have to import reload() first from module 'imp' ... now
that is just plain wrong.  :-}


import mymod

from imp import reload
reload(mymod)= now reload() will work.



Somebody out there thinks this is funny, right?

 reload(mymod)
Traceback (most recent call last):
 File pyshell#1, line 1, in module
   reload(mymod)
NameError: name 'reload' is not defined  ???




regards,
m harris
-- 
http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Alias for an attribute defined in a superclass

2011-03-31 Thread Calvin Spealman
Sounds like you're just going to end up with more confusing code
having multiple ways to refer to the exact same thing. Why?

On Thu, Mar 31, 2011 at 6:14 PM, Ben Finney ben+pyt...@benfinney.id.au wrote:
 Howdy all,

 I want to inherit from a class, and define aliases for many of its
 attributes. How can I refer to “the attribute that will be available by
 name ‘spam’ once this class is defined”?

    class Foo(object):
        def spam(self):
            pass

        def eggs(self):
            pass

    class Bar(Foo):
        beans = Foo.spam
        mash = Foo.eggs

 Is that the right way to do it? Will that leave me open to “unbound
 method” or “is not an instance of ‘Bar’” or other problems when using
 ‘Bar.beans’?

 --
  \           “If [a technology company] has confidence in their future |
  `\      ability to innovate, the importance they place on protecting |
 _o__)     their past innovations really should decline.” —Gary Barnett |
 Ben Finney
 --
 http://mail.python.org/mailman/listinfo/python-list




-- 
Read my blog! I depend on your acceptance of my opinion! I am interesting!
http://techblog.ironfroggy.com/
Follow me if you're into that sort of thing: http://www.twitter.com/ironfroggy
-- 
http://mail.python.org/mailman/listinfo/python-list


[issue11683] unittest discover should recurse into packages which are already in sys.path

2011-03-26 Thread Calvin Spealman

New submission from Calvin Spealman ironfro...@gmail.com:

For example, if I had a project with a src/ directory and inside that 
directory is a package named foo, then I can run python3 -m unittest 
discover -s . and the tests will be not be found, but I can run python3 -m 
unittest discover -s src/ and the tests in the foo package are run. This is 
because it can only find things which are in the python path, but if I have 
src/ on the path (I ran add2virtualenv src/ at some point) then discover 
should know it can traverse inside this directory.

--
messages: 132242
nosy: Calvin.Spealman
priority: normal
severity: normal
status: open
title: unittest discover should recurse into packages which are already in 
sys.path
type: feature request
versions: Python 3.2

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



[issue11683] unittest discover should recurse into packages which are already in sys.path

2011-03-26 Thread Calvin Spealman

Calvin Spealman ironfro...@gmail.com added the comment:

Doesn't it already go into multiple directories? Isn't that a requirement of a 
recursive directory walk, which I understand discover does?

I am also thinking the current documentation just doesn't make these details 
clear, so should that be another ticket if I think those should change for the 
3.2 docs to clarify the current behavior?

--

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



Re: Dump interpreter history?

2011-03-25 Thread Calvin Spealman
Tell your coworker that what he should be doing is writing good tests,
which he can rerun repeatedly while working towards a solution.
Instead of writing a new function in an interpreter, he can add tests
to confirm how he wants it to behave and then keep working on it unitl
those tests pass.

On Fri, Mar 25, 2011 at 5:03 PM, Ken D'Ambrosio k...@jots.org wrote:
 Hey, all.  A co-worker asked me a question, and I've got no idea how (or
 if) it can be done.  Bottom line: he'd like to save off the text from an
 interpreter session, his thinking being that you've already tried to get
 what you want, and now you just need to gussy it up in an editor.

 Can this be done?

 Thanks!

 -Ken




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




-- 
Read my blog! I depend on your acceptance of my opinion! I am interesting!
http://techblog.ironfroggy.com/
Follow me if you're into that sort of thing: http://www.twitter.com/ironfroggy
-- 
http://mail.python.org/mailman/listinfo/python-list


pth files and virtualenv

2011-03-23 Thread Calvin Spealman
I am not understanding why paths I'm adding to a virtualenv via
add2virtualenv are not working. I use this in plenty of other situations,
but in this one project (which is on 3.2) I am getting strange behavior.

~/projects/fooproject/#  add2virtualenv src/
~/projects/fooproject/#  python3 -c import sys;print(sys.path)
['', '~/projects/fooproject/' ...]

See? src/ is missing from the path that gets seen by Python. Did something
change in 3 that I am not realizing, which would cause this? The
virtualenv_path_extensions.pth file contains the correct path to src/, which
is the parent directory of the package I'm actually trying to import.

-- 
Read  my blog! I depend on your acceptance of my opinion! I am interesting!
http://techblog.ironfroggy.com/
Follow me if you're into that sort of thing:
http://www.twitter.com/ironfroggy
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [Python-Dev] To 3.0.2 or not to 3.0.2?

2009-02-16 Thread Calvin Spealman
FWIW; I think a 3.0.2 would be useful socially (even volunteer projects have
marketting issues to consider). It says we are committed to making 3.x
work, while the quick jump to 3.1 with only a limited minor fix release to
3.0 says we stumbled into this and have to just brush this under the rug.
But we got it right this time! I hope..

On Feb 16, 2009 2:08 PM, Lennart Regebro rege...@gmail.com wrote:

I discovered some remaining cmp() in 3.0.1, 38 minutes after Benjamin
fixed them. :) Unfortunately, that means porting setuptools to 3.0.1
will be a bit difficult. So my question is: Will there be a 3.0.2 with
those fixes, or should I add workaround code for 3.0.1?

--
Lennart Regebro: Pythonista, Barista, Notsotrista.
http://regebro.wordpress.com/
+33 661 58 14 64
___
Python-Dev mailing list
python-...@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/ironfroggy%40gmail.com
--
http://mail.python.org/mailman/listinfo/python-list


[issue5191] Partial function application 'from the right'

2009-02-09 Thread Calvin Spealman

Changes by Calvin Spealman ironfro...@users.sourceforge.net:


--
nosy: +ironfroggy

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



[issue5174] xmlrpclib docs include incorrect file closing

2009-02-06 Thread Calvin Spealman

New submission from Calvin Spealman ironfro...@users.sourceforge.net:

The following example from the xmlrpclib docs has an obviously erronous 
call to close() after the actual return. 
(http://docs.python.org/library/xmlrpclib.html)

def python_logo():
 handle = open(python_logo.jpg)
 return xmlrpclib.Binary(handle.read())
 handle.close()

The patch included also makes the whitespace PEP-8 compliant.

--
assignee: georg.brandl
components: Documentation
files: xmlrpc_doc.patch
keywords: patch
messages: 81309
nosy: georg.brandl, ironfroggy
severity: normal
status: open
title: xmlrpclib docs include incorrect file closing
versions: Python 2.5, Python 2.6, Python 2.7, Python 3.0, Python 3.1
Added file: http://bugs.python.org/file12961/xmlrpc_doc.patch

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



[issue5174] xmlrpclib docs include incorrect file closing

2009-02-06 Thread Calvin Spealman

Calvin Spealman ironfro...@users.sourceforge.net added the comment:

The patch attached uses a with statement for proper file closing in the 
examples.

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



[issue4579] .read() and .readline() differ in failing

2008-12-07 Thread Calvin Spealman

Changes by Calvin Spealman [EMAIL PROTECTED]:


--
nosy: +ironfroggy

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4579
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4579] .read() and .readline() differ in failing

2008-12-07 Thread Calvin Spealman

Calvin Spealman [EMAIL PROTECTED] added the comment:

Confirmed this behavior on my ubuntu installations but it fails properly 
on Windows.

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4579
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4573] zsh-style subpattern matching for fnmatch/glob

2008-12-07 Thread Calvin Spealman

Calvin Spealman [EMAIL PROTECTED] added the comment:

This should be applicable to 2.7, at least, as well. Here is a backport 
of the patch against trunk.

--
nosy: +ironfroggy
Added file: http://bugs.python.org/file12273/zsh-fnmatch-2.7.diff

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4573
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4573] zsh-style subpattern matching for fnmatch/glob

2008-12-07 Thread Calvin Spealman

Changes by Calvin Spealman [EMAIL PROTECTED]:


--
versions: +Python 2.7

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4573
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4331] Can't use _functools.partial() created function as method

2008-11-16 Thread Calvin Spealman

Calvin Spealman [EMAIL PROTECTED] added the comment:

I don't think this is any kind of bug, it is simply a product of only 
function objects being decorated automatically as methods. Your python 
version works because it is, in fact, a function. _functools.partial 
objects are not functions, but simply callable objects.

--
nosy: +ironfroggy

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4331
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: What do you call a class not intended to be instantiated

2008-09-21 Thread Calvin Spealman
I call it an obvious misuse and misunderstanding of why you'd use a class in
the first place. Either create an instance and not make these things
classmethods or just share the stuff in a module-level set of variables. But
the instantiating is the best options. Your class attributes might not be
globals, but you're still using global state and you should avoid it where
you can.

On Sun, Sep 21, 2008 at 6:39 PM, Steven D'Aprano 
[EMAIL PROTECTED] wrote:

 I have a class which is not intended to be instantiated. Instead of using
 the class to creating an instance and then operate on it, I use the class
 directly, with classmethods. Essentially, the class is used as a function
 that keeps state from one call to the next.

 The problem is that I don't know what to call such a thing! Abstract
 class isn't right, because that implies that you should subclass the
 class and then instantiate the subclasses.

 What do you call such a class?



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




-- 
Read my blog! I depend on your acceptance of my opinion! I am interesting!
http://techblog.ironfroggy.com/
Follow me if you're into that sort of thing:
http://www.twitter.com/ironfroggy
--
http://mail.python.org/mailman/listinfo/python-list

Re: Dynamically defined functions via exec in imported module

2008-08-15 Thread Calvin Spealman
On Fri, Aug 15, 2008 at 10:48 PM, Nadeem [EMAIL PROTECTED] wrote:
 I understand the 99% rule... the example I gave was to simplify the
 issue. The full thing I'm working on is a library for an introductory
 CS class I'm teaching. I'm trying, essentially, to build a library of
 macros for students to use allowing them to define records (like
 structs in C) with selector functions. In particular, I'm trying to
 replicate some of the Scheme stuff from the HtDP project in Python
 (http://www.htdp.org/2003-09-26/Book/curriculum-Z-
 H-9.html#node_sec_6.3). I want to provide a function, called
 defineStruct that is called like this:

 defineStruct('pos', 'x', 'y')

 The effect of this function will be to dynamically define several new
 functions for working with structures:

 makePos(x, y)
 posX(p)
 posY(p)
 isPos(p)

def defineStruct(name, *parameters):
  class _struct:
def __init__(self, *init_parameters):
  for pname, pvalue in zip(parameters, init_parameters):
setattr(self, pname, pvalue)
  globals()[make + name] = _struct
  for parameter in parameters:
def getter(o, parameter=parameter):
  return getattr(o, parameter)
globals()[name + parameter] = getter
  globals()[is + name] = lambda o: isinstance(o, _struct)

You might do other things, of course, like stepping up the frames from
sys._getframe() to inject the functions into the callers global scope.
There are some obvious optimizations you could make, too, as well as
other methods you might want to add.

 I understand that all this can be done with classes and OO
 programming, but the whole point of the HtDP curriculum is to
 introduce students to programming in a pedagogically-effective way
 using a functional approach instead of OO-first. They do it in Scheme,
 which is primarily a f.p. language, and I'm trying to replicate a
 similar approach in Python. The defineStruct thing is basically meant
 to be a macro that introduces a set of functions for whatever
 structure definition is needed.

 So, for these reasons, I don't believe the closure example above is
 helpful. I don't want to have to tell students anything about
 closures, and certainly have them worrying about functions returning
 functions, and function pointers, etc. I'm trying to bundle all that
 up behind the scenes.

 So, thinking about my problem again, an alternate question may be: Is
 it possible, in a function called in a module, to access and update
 the global definitions (dictionary or whatever) in the caller module.

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




-- 
Read my blog! I depend on your acceptance of my opinion! I am interesting!
http://techblog.ironfroggy.com/
Follow me if you're into that sort of thing: http://www.twitter.com/ironfroggy
--
http://mail.python.org/mailman/listinfo/python-list


Re: precedence of [] vs .

2008-08-14 Thread Calvin Spealman
On Thu, Aug 14, 2008 at 6:46 PM, Michael Tobis [EMAIL PROTECTED] wrote:
 I wrote some code to test the precedence of getitem vs getattr; it
 shows that getitem binds tighter.

 I have been handed some code that relies on the observed behavior.
 However, the Nutshell precedence list claims the opposite. Is the
 Nutshell wrong or am I missing something or is this a bug?

 class a(object):
def __getitem__(self,item):
return str(item)[:-1]

 class b(object):
def __getattr__(self,item):
return str(item)[::-1]

 Albert = a()
 print Albert['abcd']
 # prints 'abc'

 Barney = b()
 print Barney.abc
 # print 'cba'

 print Barney.Albert['abcd']
 # raises TypeError; tries to evaluate 'treblA'['abcd']
 # I expected 'cba' based on Nutshell 2d Ed p 50

attribute access (foo.bar) binds more tightly than subscripting (foo[bar]).

-- 
Read my blog! I depend on your acceptance of my opinion! I am interesting!
http://techblog.ironfroggy.com/
Follow me if you're into that sort of thing: http://www.twitter.com/ironfroggy
--
http://mail.python.org/mailman/listinfo/python-list


Re: You advice please

2008-08-13 Thread Calvin Spealman
Ruby (on Rails) people love to talk about Ruby (on Rails).

Python people are too busy getting things done to talk as loudly.

On Wed, Aug 13, 2008 at 11:04 AM, D'Arcy J.M. Cain [EMAIL PROTECTED] wrote:
 On Wed, 13 Aug 2008 13:47:58 +0200
 Álvaro G. Vicario [EMAIL PROTECTED] wrote:
 But I've never came across a Ruby app. Sure, I know Ruby exists and
 people are very enthusiastic about it (though they often mistake it with
 Ruby on Rails), but that's all.

 Ruby is popular among bloggers but I'm not sure whether it's popular
 among developers.

 Well, I just attended the Agile 2008 conference and sadly Ruby seemed
 to be much more popular than Python.  I found people who had heard of
 Python and were thinking of trying it but developers were working in
 Java, C++ and Ruby.

 Of course, I didn't talk to every one of the 1500 delegates.

 --
 D'Arcy J.M. Cain [EMAIL PROTECTED] |  Democracy is three wolves
 http://www.druid.net/darcy/|  and a sheep voting on
 +1 416 425 1212 (DoD#0082)(eNTP)   |  what's for dinner.
 --
 http://mail.python.org/mailman/listinfo/python-list




-- 
Read my blog! I depend on your acceptance of my opinion! I am interesting!
http://techblog.ironfroggy.com/
Follow me if you're into that sort of thing: http://www.twitter.com/ironfroggy
--
http://mail.python.org/mailman/listinfo/python-list

Re: Why nested scope rules do not apply to inner Class?

2008-08-13 Thread Calvin Spealman
On Wed, Aug 13, 2008 at 11:32 AM, Cousson, Benoit [EMAIL PROTECTED] wrote:
 Defining it as a nested class saves you one line
 of code, but IMHO makes the result just a bit more cluttered, while
 reducing the elegance of reusing the metaclass.

 The whole point of nested class is to avoid polluting the namespace with 
 classes that are only used locally. So the argument about the elegance of 
 reusing is not very valid in that case.

There is no point of nested classes because nested classes _are not_
supported by python. They are simply an artifact of not actively
denying the syntax non-globally. I would fully support a change to the
language to actively forbid a class definition that is not
module-level.

 I agree that they are other ways using module to avoid namespace pollution, 
 but in some case it is easier to use nested class instead and keep everything 
 in the same file.

I don't consider it pollution. If you want it considered private to
the module, name it with an underscore.

 In my case, I'm trying to use a similar approach as XIST's one, meaning using 
 Python class to model hierarchical data. So clearly nested class is a very 
 nice and easy understandable way to do that.

I don't find that this is clear in anyway. I can't imagine why you'd
think a nested class is even useful here, rather than an instance with
some understandable attributes. I've seen a lot of places nested
classes are used and not one of them that should be been doing it.

But, on that note, there is a point where a discussion is obviously
not going to resolve with either side changing their minds. This is
obviously such a case.

-- 
Read my blog! I depend on your acceptance of my opinion! I am interesting!
http://techblog.ironfroggy.com/
Follow me if you're into that sort of thing: http://www.twitter.com/ironfroggy
--
http://mail.python.org/mailman/listinfo/python-list


Re: You advice please

2008-08-13 Thread Calvin Spealman
God forbid I try to make a joke.

On Wed, Aug 13, 2008 at 11:20 AM, Nigel Rantor [EMAIL PROTECTED] wrote:
 Calvin Spealman wrote:

 Ruby (on Rails) people love to talk about Ruby (on Rails).

 Python people are too busy getting things done to talk as loudly.

 Have you read this list?

 I would suggest your comment indicates not.

 Throwaway comments like yours that are pithy, emotional and devoid of any
 factual content are just the kind of thing that makes lists such as this
 less useful than they could be.

 You are acting as a source of noise, not signal. I'm sure you don't want to
 be considered in that manner, so perhaps you should think about adding
 something to the conversation instead.

 Before you reply please think about what you plan on saying, you'll be
 helping not only me but yourself and anyone who reads your post.

  n




-- 
Read my blog! I depend on your acceptance of my opinion! I am interesting!
http://techblog.ironfroggy.com/
Follow me if you're into that sort of thing: http://www.twitter.com/ironfroggy
--
http://mail.python.org/mailman/listinfo/python-list


Re: Why nested scope rules do not apply to inner Class?

2008-08-13 Thread Calvin Spealman
On Wed, Aug 13, 2008 at 7:41 PM, Maric Michaud [EMAIL PROTECTED] wrote:
 I was not aware of any nested classes are unsupported before and didn't
 consider nested classes as bad practice till now, even with the pickle
 limitation (not every class are intended to be pickled), more you didn't give
 any evidence or any pertinent quote of this and at least one of Guido in the
 above threads seems contradict you :
 http://mail.python.org/pipermail/python-dev/2002-November/029906.html

Of course, I don't have to agree with Guido, but I don't really think
his comment there counts as some encouragement of the practice. It
also isn't an example that actually demonstrates the things people
misuse about nesting classes, although its definitely an example that
I think could be done much better without them, at all.

The use of nested classes to define some hierarchical structure is
subject, at best. And, the examples I see aren't even hierarchical.
The nesting doesn't seem to gain them anything. As a matter of fact,
wouldn't that example be a lot more clear with one class and some
Attribute properties describing the structure?

What rubs me the wrong way about nested classes is that they aren't
even real classes. That is, they aren't being used to instantiate
instances, but just as dummy scopes to hold some attributes. They are
abusing classes as property bags.

 BTW my concern was not really about nested classes but the asymetry between
 function scope and classes scope, there are at least two examples that come
 to my mind and for which I don't see good argument to keep the situation as
 it is. First is the very odd behavior of genexp, second is the dynamic type
 factory, I know it's not a big deal to in each case and can live with this,
 but these pieces of code fail unexpectedly while even a experimented python
 programmer would have thought they work at first glance, and the explanation
 of why they fail to a newcomer is not easy (specially for the first)

 (1) this fail  only on the last line while it would have work well with
 listcomp and works well in a function definition
 class A(object) :
l = range(5)
m = list(a+b for a in l for b in range(5))
n = list(a+b for a in range(5) for b in l)

I can admit that this behavior can be surprising, but it isn't
something I really see cropping up as a problem. How often do you see
that you need to have any kind of procedural behavior in a class body?
In other words, in all but rare cases, the order of the class body
lines shouldn't change the resulting class, but this example breaks
that expectation.

 (2) This won't work as it would with nested functions, you need to build the
 new calss directly with type('dynamic', (object,), {type_: type_})

 def create_type(type_) :
class dynamic(object) :
type_ = type_
return dynamic

This is simply completely invalid. That code at the beginning of any
body will _always_ raise either an UnboundLocalError or a NameError,
because you are assigning to the same name you are dereferencing. That
line will always be either an error or a no-op, anywhere it appears.
It has nothing to do with nesting of any sort.


 --
 _

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



-- 
Read my blog! I depend on your acceptance of my opinion! I am interesting!
http://techblog.ironfroggy.com/
Follow me if you're into that sort of thing: http://www.twitter.com/ironfroggy
--
http://mail.python.org/mailman/listinfo/python-list


  1   2   3   >