Python doesn't work

2021-05-30 Thread Mr . Incognito
   Hello

   I downloaded the latest versioon of Python and tried to open several .py
   files, but it doesn't open. It opens for a sec, then closes itself. I
   tried uninstalling and reinstalling, but it doesn't work.



   I hope you can help me!





   Saadetud Windows 10 rakendusest [1]Meil



References

   Visible links
   1. https://go.microsoft.com/fwlink/?LinkId=550986
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: neoPython : Fastest Python Implementation: Coming Soon

2021-05-05 Thread Mr Flibble

On 05/05/2021 17:36, Igor Korot wrote:

Hi,

On Wed, May 5, 2021 at 11:27 AM Mr Flibble <
flib...@i42.invalidwibblegrok.co.uk> wrote:


On 05/05/2021 17:02, Chris Angelico wrote:

On Thu, May 6, 2021 at 2:01 AM Mr Flibble
 wrote:


neoPython : Fastest Python Implementation: Coming Soon

Message ends.

/Flibble



My breath: not being held.

Message ends.


Why? The currently extant Python implementations are so inefficient they
contribute to climate change; CPython is particularly egregious. Making a
faster
implementation isn't in the least bit a stretch.

Message ends.



Why do you use {C}Python in the first place if its so inefficient?
Why not use C or even Assembly?

And "coming soon" - is a little weird.
Why not say "coming 10 May 2021 at 23:59:59"?

/Message ends.

Thank you.


But I don't use Python, I use C++ (probably the best programming language in the 
world).


/Flibble

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


Re: neoPython : Fastest Python Implementation: Coming Soon

2021-05-05 Thread Mr Flibble

On 05/05/2021 17:33, Mark Lawrence wrote:

On Wednesday, May 5, 2021 at 4:57:13 PM UTC+1, Mr Flibble wrote:

neoPython : Fastest Python Implementation: Coming Soon

Message ends.

/Flibble

--
😎

Dedicated to you and all like you https://www.youtube.com/watch?v=X15PsqN0DHc


ORLY? If anyone is thick around here it is the typical Python user such as 
yourself.

/Flibble

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


Re: neoPython : Fastest Python Implementation: Coming Soon

2021-05-05 Thread Mr Flibble

On 05/05/2021 17:02, Chris Angelico wrote:

On Thu, May 6, 2021 at 2:01 AM Mr Flibble
 wrote:


neoPython : Fastest Python Implementation: Coming Soon

Message ends.

/Flibble



My breath: not being held.

Message ends.


Why? The currently extant Python implementations are so inefficient they 
contribute to climate change; CPython is particularly egregious. Making a faster 
implementation isn't in the least bit a stretch.


Message ends.

/Flibble

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


Re: neoPython : Fastest Python Implementation: Coming Soon

2021-05-05 Thread Mr Flibble

On 05/05/2021 17:02, Chris Angelico wrote:

On Thu, May 6, 2021 at 2:01 AM Mr Flibble
 wrote:


neoPython : Fastest Python Implementation: Coming Soon

Message ends.

/Flibble



My breath: not being held.

Message ends.


Why? The currently extant Python implementations contribute to climate change as 
they are so inefficient; CPython is so egregious it is best called a bag of 
shite. Making a faster implementation isn't in the least bit a stretch.


Message ends.

/Flibble

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


neoPython : Fastest Python Implementation: Coming Soon

2021-05-05 Thread Mr Flibble

neoPython : Fastest Python Implementation: Coming Soon

Message ends.

/Flibble

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


Re: New Python implementation

2021-02-14 Thread Mr Flibble

On 14/02/2021 23:00, Christian Gollwitzer wrote:

Am 14.02.21 um 11:12 schrieb Paul Rubin:

Christian Gollwitzer  writes:

He wants that neoGFX is scriptable in Python, but instead of linking
with CPython, he will write his own Python implementation instead,
because CPython is slow/not clean/ whatever. He doesn't seem to
understand that this is an enormous task on its own, because the
interesting part of a scripting language is the standard library with
many decade-years of work.


I wonder how big an issue the stdlib really is.Β  Lots of it is written
in Python and can port to another interpreter.Β  Lots more is CPython C
API bindings to external C libraries (e.g. OpenSSL) so porting those
would be a matter of rebinding those libraries to libffi in the cases
where that hasn't been done already.


I'm not saying that it is unfeasible or very difficult. I'm saying that it is a lot of work, and for a single 
developer who has this as a side project / support for his graphics engine and who wants to beat existing 
implementations wrt. speed, I'm saying it is going to take a lot of time. It'definitely impossible by 
"defining a few JSON schema files", as Leigh claims with his "universal compiler". There 
definitely IS a lot of stuff in a baseline CPython interpreter - a (seemingly) simple thing like 
"print" will have an implementation of 1000 lines in C with all the formatting library, file I/O 
etc. Arbitrary precision integers - another library, networking - yet another and so on.


There will only be one schema file and it is will be a relatively small task which certainly isn't 
"impossible": I should have a working implementation by the summer.  As far as arbitrary 
precision integers are concerned I am well on the way to completing the "neonumeral" 
library (which also has arbitrary precision floats).

As far as the standard library is concerned: that is already in Python so I 
should be able to support it with little effort; the only thing requiring more 
work would be the built-ins.




CPython really is pretty slow, maybe because it uses so much boxed data,
derps around with refcounts all the time, suffers memory fragmentation
from not having a relocating GC, etc.Β  And that is before we even
mention the GIL.


I don't argue with that. CPython is slow. But I'm arguing that you can't make 
it faster by multiple orders of magnitude unless you change the language. For 
numerical code, straight-forward C is usually 100x to 1000x faster than Python, 
and you can reach the same performance by giving up dynamic typing - Cython 
demonstrates this quite convincingly. If you don't want static typing (with 
types close to the machine like fixed-width integers) than you'll have to 
resort to a LOT of black magic to even come close (PyPy, modern JS engines, 
)


I believe PyPy is only 4x faster than CPython on average and comes nowhere near 
close to JS JIT engines performance-wise.

/Flibble

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


Re: Change first occurrence of character x in a string - how?

2021-02-14 Thread Mr Flibble

On 14/02/2021 21:14, Chris Green wrote:

What's the easiest way to change the first occurrence of a specified
character in a string?


By using a grown up (i.e. non-toy) programming language.

/Flibble

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


Re: Sketch

2021-02-14 Thread Mr Flibble

On 14/02/2021 09:10, MichaΕ‚ Jaworski wrote:

Wow, that thread is entertaining. It seems that neos is one of it’s kind. What 
I hope is that it will support TempleOS.

Going back going back to your original question Mr. Fibble. If ISO standard is 
what you really need to finish your project you can always take up this 
challenge and standardize the language yourself. From what I’ve learned already 
you have enough skills, experience and perseverance to complete such endeavor 
single-handedly.


Ah yes, the good old TempleOS equivalence ploy: typically used by backseat 
programmers and/or trolls to dismiss projects or project authors they deem to 
have no value based on subjective hyperbole rather than valid criticism based 
on objective fact. Usually they lack the skill to embark on such a project 
themselves so their invective tends to stem from feelings of inadequacy.

Make yourself a cup of tea, dear.

/Flibble

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


Re: Sketch

2021-02-14 Thread Mr Flibble

On 14/02/2021 09:10, MichaΕ‚ Jaworski wrote:

Wow, that thread is entertaining. It seems that neos is one of it’s kind. What 
I hope is that it will support TempleOS.

Going back going back to your original question Mr. Fibble. If ISO standard is 
what you really need to finish your project you can always take up this 
challenge and standardize the language yourself. From what I’ve learned already 
you have enough skills, experience and perseverance to complete such endeavor 
single-handedly.


If I standardized the language myself I couldn't call it "Python" as fixing 
Python requires changing it such as to make it unrecognisable as Python.

/Flibble

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


Re: Sketch

2021-02-13 Thread Mr Flibble

On 14/02/2021 05:04, Mark Lawrence wrote:

On Sunday, February 14, 2021 at 5:01:46 AM UTC, Mr Flibble wrote:

CPython *is* the dead parrot.

It's time for Python to evolve out of the primordial soup.

/Flibble

--
😎


Says the bloke(?) who doesn't use mailing lists but does get here 
https://mail.python.org/pipermail/python-list/2021-February/900797.html


I am using Usenet, dear. Apparently posts to comp.lang.python are copied to the 
mailing list which you worship like a god.

/Flibble

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


Sketch

2021-02-13 Thread Mr Flibble

CPython *is* the dead parrot.

It's time for Python to evolve out of the primordial soup.

/Flibble

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


Re: New Python implementation

2021-02-13 Thread Mr Flibble

On 14/02/2021 03:26, Grant Edwards wrote:

On 2021-02-14, Ned Batchelder  wrote:

On Saturday, February 13, 2021 at 7:19:58 PM UTC-5, Chris Angelico wrote:


At the absolute least, show that you have something that can run Python code.


The OP has been making these claims on IRC for a (at least two
years). He has never cared to substantiate them, or even participate
in a civil and detailed discussion.  He is either 1) smarter than
all of us, or 2) woefully under-informed, or 3) trolling.


He posts using the name of a hand-puppet. I think that provides a bit
of a clue as to which of the 3 is most likely. And it's not even a
_real_ hand-puppet: it's a computer-generated hologram of a hand
hand-puppet.


lulz. If I am a troll then Elon Musk is also a troll.

/Flibble

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


Re: New Python implementation

2021-02-13 Thread Mr Flibble

On 14/02/2021 00:52, Alan Gauld wrote:

On 14/02/2021 00:07, Mr Flibble wrote:

On 13/02/2021 18:11, Alan Gauld wrote:



You are going to create a Python compiler that will take existing
Python code and output a byte code file.


No neos is not a Python compiler: it is a *universal* compiler that
can compile any programming language describable by a schema file


Yes, I understand that, but from the perspective of this list
what you are doing is providing a tool (a combination of neos
and a schema) that will take in Python source code and spit out
neos byte code. So, to all intents and purposes it is a Python
compiler (albeit capable of more when needed).


If that's correct, then how do you propose to deal with
regular Python byte code? And what would the Python disassembler
produce - Python assembler instructions or neos?


The neos Python implementation will not be dealing
with Python byte code in any form whatsoever.


Ok  but what do you do with the disassembler module?
Will it read neos byte code instead of the Python codes?
Also what about tools that work at the byte code level,
I assume they will not work with neos either?
That might include the profiler and debugger for example?


neos will include a language agnostic disassembler and debugger.



Also what would happen with the interactive prompt (>>>)
I'm assuming you'd expect users to continue using the CPython
interpreter and only compile the source after it was working
there? Like turning on the optimiser in a traditional
compiled language like C.


neos will include support for interactive sessions; no reason to use CPython at 
all.

/Flibble

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


Re: New Python implementation

2021-02-13 Thread Mr Flibble

On 14/02/2021 02:54, Mark Lawrence wrote:

On Sunday, February 14, 2021 at 2:18:03 AM UTC, Mr Flibble wrote:

On 14/02/2021 00:51, Ned Batchelder wrote:
  

The OP has been making these claims on IRC for a while (at least two years). He 
has never cared to substantiate them, or even participate in a civil and 
detailed discussion. He is either 1) smarter than all of us, or 2) woefully 
under-informed, or 3) trolling. Our best course is to ignore him until he has 
code we can try.

I am sure you are most annoyed that you can't ban me from Usenet, dear, like 
you banned me from IRC. You need to grow the fuck up.


I take it that you didn't write "How to win friends and influence people"?  I 
don't suppose that the moderators will actually wake up and remove you from the mailing 
lists asap.


I see you are just as prickly as Ned, Mark. May I suggest that you too grow a 
pair? I am not on the mailing list BTW; e-mail lists are an outmoded concept 
much like CPython.

/Flibble

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


Re: New Python implementation

2021-02-13 Thread Mr Flibble

On 14/02/2021 03:35, Paul Rubin wrote:

Mr Flibble  writes:

I am creating neos as I need a performant scripting engine for my
other major project "neoGFX" and I want to be able to support multiple
popular scripting languages including Python.


Is something wrong with Guile for that purpose?  If yes, maybe you are
setting yourself up for the exact same obstacles ;-).


NIH.

/Flibble

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


Re: New Python implementation

2021-02-13 Thread Mr Flibble

On 14/02/2021 00:51, Ned Batchelder wrote:

On Saturday, February 13, 2021 at 7:19:58 PM UTC-5, Chris Angelico wrote:

On Sun, Feb 14, 2021 at 11:14 AM Mr Flibble
 wrote:


On 13/02/2021 23:30, Igor Korot wrote:

Hi,
But most importantly - what is the reason for this ?
I mean - what problems the actual python compiler produce?

Thank you.


I am creating neos as I need a performant scripting engine for my other major project 
"neoGFX" and I want to be able to support multiple popular scripting languages 
including Python.


Until you have actually produced a (mostly) compatible Python
implementation, can you please stop making these repeated and baseless
jabs at CPython's performance? You keep stating or hinting that
CPython is somehow unnecessarily slow, but unless you have some code
to back your claims, this is nothing but mudslinging.

CPython is not as slow as you might think. And PyPy is highly
efficient at what it does well. Show us that you can do better than
these before you call them slow.

At the absolute least, show that you have something that can run Python code.

ChrisA


The OP has been making these claims on IRC for a while (at least two years). He 
has never cared to substantiate them, or even participate in a civil and 
detailed discussion.  He is either 1) smarter than all of us, or 2) woefully 
under-informed, or 3) trolling.  Our best course is to ignore him until he has 
code we can try.


I am sure you are most annoyed that you can't ban me from Usenet, dear, like 
you banned me from IRC. You need to grow the fuck up.

Your use of the words "all of us" is disingenuous, try "me" instead.  "All of 
us" includes people as smart as me but can't be arsed fixing the Python space because they can just 
about live with the status quo.

/Flibble

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


Re: New Python implementation

2021-02-13 Thread Mr Flibble

On 14/02/2021 00:19, Chris Angelico wrote:

On Sun, Feb 14, 2021 at 11:14 AM Mr Flibble
 wrote:


On 13/02/2021 23:30, Igor Korot wrote:

Hi,
But most importantly - what is the reason for this ?
I mean - what problems the actual python compiler produce?

Thank you.


I am creating neos as I need a performant scripting engine for my other major project 
"neoGFX" and I want to be able to support multiple popular scripting languages 
including Python.



Until you have actually produced a (mostly) compatible Python
implementation, can you please stop making these repeated and baseless
jabs at CPython's performance? You keep stating or hinting that
CPython is somehow unnecessarily slow, but unless you have some code
to back your claims, this is nothing but mudslinging.

CPython is not as slow as you might think. And PyPy is highly
efficient at what it does well. Show us that you can do better than
these before you call them slow.

At the absolute least, show that you have something that can run Python code.


It isn't just me that is saying CPython is egregiously slow: it is at the 
bottom of the list as far as performance is concerned. Python is undoubtedly 
the biggest contributor to climate change of all the programming languages in 
mainstream use today.

See: 
https://thenewstack.io/which-programming-languages-use-the-least-electricity/

/Flibble

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


Re: New Python implementation

2021-02-13 Thread Mr Flibble

On 13/02/2021 23:30, Igor Korot wrote:

Hi,
But most importantly - what is the reason for this ?
I mean - what problems the actual python compiler produce?

Thank you.


I am creating neos as I need a performant scripting engine for my other major project 
"neoGFX" and I want to be able to support multiple popular scripting languages 
including Python.

/Flibble

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


Re: New Python implementation

2021-02-13 Thread Mr Flibble

On 13/02/2021 18:11, Alan Gauld wrote:

On 13/02/2021 16:09, Mr Flibble wrote:

On 13/02/2021 00:01, Alan Gauld wrote:

I'm assuming it's a new executable interpreter that can run any
valid python code. Is that correct?


It is a universal *compiler* so it compiles the python code to byte code
and then optionally to machine code via a JIT which is then executed.


OK, sorry for being dense, but just to be absolutely clear.

You are going to create a Python compiler that will take existing
Python code and output a byte code file. (I assume the byte code
is not standard Python byte code?) And I assume the execution
environment for the bytecode is part of your neos system?


No neos is not a Python compiler: it is a *universal* compiler that can compile 
any programming language describable by a schema file and any language-specific 
semantic concepts.  The byte code will be proprietary, yes, and will be 
executed by neos and/or JITed.



If that's correct, then how do you propose to deal with
regular Python byte code? And what would the Python disassembler
produce - Python assembler instructions or neos?


The neos Python implementation will not be dealing with Python byte code in any 
form whatsoever.

/Flibble

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


Re: New Python implementation

2021-02-13 Thread Mr Flibble

On 13/02/2021 00:01, Alan Gauld wrote:

On 12/02/2021 21:46, Mr Flibble wrote:


The neos Python implementation will consist of a schema file
which describes the language plus any Python-specific semantic concepts


So the schema file is some kind of formal grammar definition of
the language?

And you "compile" this directly into machine code?
Is that the idea?

So when you say you have a universal compiler for any language
what you mean is that you can produce a compiler/interpreter
for any language from a language definition/schema. Is that it?

I'm still not sure I understand what exactly you are proposing
to do. What the final output looks like?

I'm assuming it's a new executable interpreter that can run any
valid python code. Is that correct?


It is a universal *compiler* so it compiles the python code to byte code and 
then optionally to machine code via a JIT which is then executed.

/Flibble

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


Re: New Python implementation

2021-02-12 Thread Mr Flibble

On 12/02/2021 00:15, Alan Gauld wrote:

On 11/02/2021 12:30, Mr Flibble wrote:


I am starting work on creating a new Python implementation
from scratch using "neos" my universal compiler that can
compile any programming language.


Can i clarify that?
Are you saying that you are going to recompile the existing
C code for pyhton using yoour universal compiler and the
resulting binary file will be a new implementation of
the interpreter that you expect to be faster?


Nope.



That's what it sounds like to me.
In which case the question is not whether you can write a
better interpreter than CPython but whether you can write
a better compiler than GNU/MING/VC etc


See previous answer.



While a universal compiler is  certainly an interesting
and challenging project I'm not sure how much it tells us
about existing Python implementations.


The two things are unrelated; however it is well known that Python is slow.



On the other hand, if you are planning on rewriting the
existing interpreter in something other than C, what
is that something?


Nope.




Sample neos session (parsing a fibonacci program,
neoscript rather than Python in this case):


I'm not sure what relevance this has unless you want
to rewrite Python in neoscript? Or are you translating
the C into neoscript and then compiling it? But in a
later response you seem to say neoscript was not involved?

Slightly confused...



The neos Python implementation will consist of a schema file which describes 
the language plus any Python-specific semantic concepts that don't generalize 
to more than one language.

/Flibble

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


Re: New Python implementation

2021-02-12 Thread Mr Flibble

On 12/02/2021 02:45, Terry Reedy wrote:

On 2/11/2021 5:33 PM, Mr Flibble wrote:

On 11/02/2021 22:25, Dan Stromberg wrote:

On Thu, Feb 11, 2021 at 2:00 PM Mr Flibble 
wrote:


On 11/02/2021 21:13, Dan Stromberg wrote:

Does your project have a name yet?Β  I'd like to follow it through google
alerts or an announcement mailing list.


"neos" - https://neos.dev/ https://github.com/i42output/neos



Pypi already appears to have another project named neos:
https://pypi.org/project/neos/


neos isn't a Python package so that isn't a problem.


Since it obviously is a Python package, as in importable into a Python program, 
why do you deny it?


You are mistaken: it isn't a Python package and it isn't importable into a 
Python program.

/Flibble

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


Re: New Python implementation

2021-02-11 Thread Mr Flibble

On 11/02/2021 23:05, Paul Rubin wrote:

Mr Flibble  writes:

"neos" - https://neos.dev/ https://github.com/i42output/neos


Good luck, let us know when it is done.  What is there doesn't look like
a credible start so far, but maybe you will surprise us.  Have you
actually written any code in the languages you say you are going to
support?  E.g. Ada, Haskell, Rust.  I'd agree that Python is fairly
simple compared to those.


Not credible? On what do you base that analysis?

/Flibble

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


Re: New Python implementation

2021-02-11 Thread Mr Flibble

On 11/02/2021 23:12, Greg Ewing wrote:

On 12/02/21 11:33 am, Mr Flibble wrote:

neos isn't a Python package so that isn't a problem.


It might be a bit confusing if it ever becomes part of the
wider Python ecosystem, though.

 Python is but one language that neos will implement.

/Flibble

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


Re: New Python implementation

2021-02-11 Thread Mr Flibble

On 11/02/2021 22:25, Dan Stromberg wrote:

On Thu, Feb 11, 2021 at 2:00 PM Mr Flibble 
wrote:


On 11/02/2021 21:13, Dan Stromberg wrote:

Does your project have a name yet?  I'd like to follow it through google
alerts or an announcement mailing list.


"neos" - https://neos.dev/ https://github.com/i42output/neos



Pypi already appears to have another project named neos:
https://pypi.org/project/neos/


neos isn't a Python package so that isn't a problem.

/Flibble

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


Re: New Python implementation

2021-02-11 Thread Mr Flibble

On 11/02/2021 21:13, Dan Stromberg wrote:

Does your project have a name yet?  I'd like to follow it through google
alerts or an announcement mailing list.


"neos" - https://neos.dev/ https://github.com/i42output/neos

/Flibble

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


Re: New Python implementation

2021-02-11 Thread Mr Flibble

On 11/02/2021 18:24, Paul Bryan wrote:

On Thu, 2021-02-11 at 17:56 +, Mr Flibble wrote:


Actually it is a relatively small task due to the neos universal
compiler's architectural design.Β  If it was a large task I wouldn't
be doing it.


When do you estimate this task will be completed?


I am not particularly interested in any of the existing
implementations as they bear no relation to the design of my language
agnostic universal compiler, runtime, VM and JIT; the only use they
will have will be to disambiguate certain Python language constructs
that I cannot disambiguate from documentation alone: this is a
natural consequence of Python not being standardized; those steering
the language need to grow a pair and get Python standardized
preferably as an ISO Standard.


I take it you don't hope to receive any support from those you're
insulting by such a statement?


Thanks for the sentiment but I am not relying on luck.


By your conduct so far, I think you will also not be relying on the
goodwill of this community.


Personally I prefer telling it like it is (i.e. the truth) rather than walking 
on eggshells.

/Flibble

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


Re: New Python implementation

2021-02-11 Thread Mr Flibble

On 11/02/2021 18:06, Chris Angelico wrote:

On Fri, Feb 12, 2021 at 5:01 AM Mr Flibble
 wrote:


On 11/02/2021 16:31, Dan Stromberg wrote:

On Thu, Feb 11, 2021 at 4:35 AM Mr Flibble 
wrote:



Hi!

I am starting work on creating a new Python implementation from scratch
using "neos" my universal compiler that can compile any programming
language.  I envision this implementation to be significantly faster than
the currently extant Python implementations (which isn't a stretch given
how poorly they perform).



I'd like to encourage you to give this a go.  It's a huge task, but it's
needed.


Actually it is a relatively small task due to the neos universal compiler's 
architectural design.  If it was a large task I wouldn't be doing it.



You may be interested in the approaches of Pypy, Cython, Shedskin and
Nuitka.


I am not particularly interested in any of the existing implementations as they 
bear no relation to the design of my language agnostic universal compiler, 
runtime, VM and JIT; the only use they will have will be to disambiguate 
certain Python language constructs that I cannot disambiguate from 
documentation alone: this is a natural consequence of Python not being 
standardized; those steering the language need to grow a pair and get Python 
standardized preferably as an ISO Standard.



You keep insulting Python and the Python devs. Put up or shut up -
show some actual code before you make too many boasts.

Python DOES have a strong language specification. Its semantics are
documented. If you find places where the documentation is lacking,
point them out specifically, don't FUD your way through.


For a language to transition from "toy" status it has to be formally 
standardized.  It is unacceptable to define a language in terms of a particular 
implementation. A git repo of Source code and associated observable dynamic behaviour 
when that code is compiled and ran is a poor substitute for an official ISO Standard.

/Flibble

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


Re: New Python implementation

2021-02-11 Thread Mr Flibble

On 11/02/2021 18:03, Chris Angelico wrote:


In any case, it's not Python if it can't handle arbitrarily large
numbers. Python is an excellent language for mathematics.


I am also creating Ada and Haskell implementations which have a similar 
requirement.

/Flibble

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


Re: New Python implementation

2021-02-11 Thread Mr Flibble

On 11/02/2021 16:31, Dan Stromberg wrote:

On Thu, Feb 11, 2021 at 4:35 AM Mr Flibble 
wrote:



Hi!

I am starting work on creating a new Python implementation from scratch
using "neos" my universal compiler that can compile any programming
language.  I envision this implementation to be significantly faster than
the currently extant Python implementations (which isn't a stretch given
how poorly they perform).



I'd like to encourage you to give this a go.  It's a huge task, but it's
needed.


Actually it is a relatively small task due to the neos universal compiler's 
architectural design.  If it was a large task I wouldn't be doing it.



You may be interested in the approaches of Pypy, Cython, Shedskin and
Nuitka.


I am not particularly interested in any of the existing implementations as they 
bear no relation to the design of my language agnostic universal compiler, 
runtime, VM and JIT; the only use they will have will be to disambiguate 
certain Python language constructs that I cannot disambiguate from 
documentation alone: this is a natural consequence of Python not being 
standardized; those steering the language need to grow a pair and get Python 
standardized preferably as an ISO Standard.



Pypy is a Python written in RPython, where RPython is a restricted subset
of Python 2.  It can translate RPython to C, or JIT compile pretty full
Python code - 2.x or 3.x.  It has trouble with C extension modules, as the
CPython API for extension modules is pretty leaky. CFFI appears to be the
big hope of fixing this problem, but most C extension modules still use the
CPython C extension Module API.


RPython doesn't interest me. neos will be using libffi for FFI.



Cython transpiles a Python-like language to C.  It allows you to intermix
Python datatypes and C datatypes; the more you use C datatypes, the faster
the result is.  It can be slower if you aren't careful with your type
conversions, but it can be faster if used well.  It has a really nice
--annotate option that shows how close to C your program is, line by line.


I don't agree with the concept of delivering C compilers to end users. The only 
compilers I think end users should be running are GPU shader compilers and 
byecode/JIT compilers such as neos.



Shedskin transpiles an implicitly static subset of Python 2 to C++.  It's a
great tool, but sadly it is unlikely to make the jump from Python 2 to
Python 3, and Python 3 is definitely the future of Python.


Not interested in that (see previous answer replacing "C" with "C++").



Nuitka is a Python -> C/C++ transpiler.  I know little about it, but it
sounds kind of like what you're proposing.  It's been focusing on
compatibility first, followed by performance.


Bears no relation to neos architecture.



Good luck!


Thanks for the sentiment but I am not relying on luck.

/Flibble

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


Re: New Python implementation

2021-02-11 Thread Mr Flibble

On 11/02/2021 15:13, Chris Angelico wrote:

On Thu, Feb 11, 2021 at 11:36 PM Mr Flibble
 wrote:



Hi!

I am starting work on creating a new Python implementation from scratch using 
"neos" my universal compiler that can compile any programming language.


Is it your intention to support all of Python's syntax and semantics,


Yes.


or is this an unrelated language with mandatory strict type tags and a
severely restricted set of data types? For instance, can your neos
compile this code?


No. The neos universal compiler itself is language agnostic: a pre-requisite 
for the requirement to be able to compile any programming language.



def power():
 return (2**3**4**2) % 10

from time import time
start = time()
print(power())
time = time() - start
print("Took %s seconds" % time)

On my system, I get this from CPython 3.10:
176561152
Took 0.1589798927307129 seconds

And this from PyPy:
176561152
Took 0.0233387947083 seconds


I envision this implementation to be significantly faster than the currently 
extant Python implementations (which isn't a stretch given how poorly they 
perform).


Riight, yep, all existing Python implementations are terribly
slow. Go ahead then; run the code above, show me a better time, and of
course compare to what a recent off-the-shelf CPython can do on the
same hardware. Then see how PyPy performs at the same job.


You are timing the arithmetic library rather than the interpreter.




Sample neos session (parsing a fibonacci program, neoscript rather than Python 
in this case):


Is neoscript an intermediate language like RPython, used only to
implement the compiler, or are you actually transforming Python code
into neoscript?


neoscript is the neos reference language (i.e. not an intermediate language) 
and will be unrelated to the Python implementation.

/Flibble

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


New Python implementation

2021-02-11 Thread Mr Flibble


Hi!

I am starting work on creating a new Python implementation from scratch using 
"neos" my universal compiler that can compile any programming language.  I 
envision this implementation to be significantly faster than the currently extant Python 
implementations (which isn't a stretch given how poorly they perform).

Sample neos session (parsing a fibonacci program, neoscript rather than Python 
in this case):

neos 1.0.0.0 ED-209
] help
h(elp)
s(chema)Load language schema
l(oad)  Load program
list List program
c(ompile)Compile program
r(un)Run program
![]  Evaluate expression (enter interactive 
mode if expression omitted)
: Input (as stdin)
q(uit)   Quit neos
lc   List loaded concept libraries
t(race) <0|1|2|3|4|5> [] Compiler trace
m(etrics)Display metrics for running programs
] lc
[neos.core] (file:///D:\code\neos\build\win32\vs2019\x64\Release\core.ncl)
  [neos.boolean]
  [neos.language]
  [neos.logic]
  [neos.math]
  [neos.module]
  [neos.object]
  [neos.string]
[neos.math.universal] 
(file:///D:\code\neos\build\win32\vs2019\x64\Release\core.math.universal.ncl)
] s neoscript
Loading schema 'neoscript'...
Language: Default neoGFX scripting language
Version: 1.0.0
Copyright (C) 2019 Leigh Johnston
neoscript] l examples/neoscript/fibonacci.neo
neoscript] list
File 'examples/neoscript/fibonacci.neo':
-- neoscript example: Fibonacci

using neos.string;
using neos.stream;

import fn to_string(x : i32) -> string;
import fn to_integer(s : string) -> i32;
import proc input(s : out string);
import proc print(s : in string);

-- functions are pure
def fn add(x, y : i32) -> i32
{
return x + y;
}
def fn fib(x : i32) -> i32
{
if (x < 2)
return 1;
else
return add(fib(x-1), fib(x-2));
}

-- procedures are impure
def proc main()
s : string;
{
print("Enter a positive "
"integer: ");
input(s);
print("Fibonacci(" + s + ") = " + to_string(fib(to_integer(s))) + "\n");
}
neoscript] t 1
neoscript] c
folding: string.utf8() <- string.utf8.character.alpha()
folded: string.utf8() <- string.utf8.character.alpha() = string.utf8(g)
folding: string.utf8(g) <- string.utf8.character.alpha()
folded: string.utf8(g) <- string.utf8.character.alpha() = string.utf8(gn)
folding: string.utf8(gn) <- string.utf8.character.alpha()
folded: string.utf8(gn) <- string.utf8.character.alpha() = string.utf8(gni)
folding: string.utf8(gni) <- string.utf8.character.alpha()
folded: string.utf8(gni) <- string.utf8.character.alpha() = string.utf8(gnir)
folding: string.utf8(gnir) <- string.utf8.character.alpha()
folded: string.utf8(gnir) <- string.utf8.character.alpha() = string.utf8(gnirt)
folding: string.utf8(gnirt) <- string.utf8.character.alpha()
folded: string.utf8(gnirt) <- string.utf8.character.alpha() = 
string.utf8(gnirts)
folding: string.utf8(gnirts) <- string.utf8.character.period()
folded: string.utf8(gnirts) <- string.utf8.character.period() = 
string.utf8(gnirts.)
folding: string.utf8(gnirts.) <- string.utf8.character.alpha()
folded: string.utf8(gnirts.) <- string.utf8.character.alpha() = 
string.utf8(gnirts.s)
folding: string.utf8(gnirts.s) <- string.utf8.character.alpha()
folded: string.utf8(gnirts.s) <- string.utf8.character.alpha() = 
string.utf8(gnirts.so)
folding: string.utf8(gnirts.so) <- string.utf8.character.alpha()
folded: string.utf8(gnirts.so) <- string.utf8.character.alpha() = 
string.utf8(gnirts.soe)
folding: string.utf8(gnirts.soe) <- string.utf8.character.alpha()
folded: string.utf8(gnirts.soe) <- string.utf8.character.alpha() = 
string.utf8(gnirts.soen)
folding: source.package.name() <- string.utf8(gnirts.soen)
folded: source.package.name() <- string.utf8(gnirts.soen) = 
source.package.name(neos.string)
folding: source.package.import() <- source.package.name(neos.string)
folded: source.package.import() <- source.package.name(neos.string) = 
source.package.import(neos.string)
folding: source.package.import(neos.string) <- 
source.package.import(neos.string)
folding: string.utf8() <- string.utf8.character.alpha()
folded: string.utf8() <- string.utf8.character.alpha() = string.utf8(g)
folding: string.utf8(g) <- string.utf8.character.alpha()
folded: string.utf8(g) <- string.utf8.character.alpha() = string.utf8(gn)
folding: string.utf8(gn) <- string.utf8.character.alpha()
folded: string.utf8(gn) <- string.utf8.character.alpha() = string.utf8(gni)
folding: string.utf8(gni) <- string.utf8.character.alpha()
folded: string.utf8(gni) <- string.utf8.character.alpha() = string.utf8(gnir)
folding: string.utf8(gnir) <- string.utf8.character.alpha()
folded: string.utf8(gnir) <- string.utf8.character.alpha() = string.utf8(gnirt)
folding: string.utf8(gnirt) <- string.utf8.character.alpha()
folded: 

Python question

2020-03-07 Thread Mr . Lee Chiffre
Thank you Marco for at least taking the time to read my message even if you do 
not agree with me on things. And no disrespect to you. But I came here for 
python related questions and help. Not to be called suspicious and 
untrustworthy only because I am concerned about security of users and for being 
a advocate of privacy. Then to call for me to be censored is just ludicrous.


> People of Python List, I strongly discourage you to support this user.
> He is quite suspicious for the following reasons:
>
> 1. he go so far as he offers money for, IMHO, a trivial task

I said I am a python noob. This is why I asked for help. And I see no issue in 
offering payment for a programming task.

> 2. he does not trust binaries from pip.

What is the point of open source if you cannot compile from source code?

> code. A lack of trust in open source projects that is quite unusual
> 3. I don't trust any cryptocurrency.

Not unusual. People use open source because they dont trust closed source. 
Binaries that someone else compiled is not open source.

> I believe in privacy,  but not in financial privacy. Yes,
> cryptocurrencies can be useful for circumvent bans from tyrannic
> states. But they can, and _are_ used, primarily to:
>  - wash dirty money, by criminals and mafias
>  - evade taxes
>  - buy highly unethical "products", like weapons... and who know what
> other
>  - finance tyrannies.

Roads and cars are used by drug dealers. Stop using roads and cars. Cash is 
used by criminals. Stop using cash. Internet is used by child abusers. Stop 
supporting the internet. I am offended that you group me with criminals and 
baddies because I support technological privacy.


>
> I do _not_ think that all people that uses cryptocurrencies are
> criminals. I had, for example, some co-workers that invested in
> BitCoins, only for profit.
>
> But I do not trust this man, and I hope no one will offer support to
> him. By my side, I'll report this discussion to moderators.

That is fine if you dont like something. You dont have to help me out if you 
dont want to. But trying to censor me is unethical. Hopefully other people will 
have the logic to make decisions for themselves and give me help on python if 
they choose to do so.

I hope my reply does not get censored. I am being reasonable here. And if you 
are wondering why I am "paranoid", you would be too if you are dealing with a 
server that might host a hot wallet. I dont want my server getting hacked just 
because I was too lazy to compile my own code. And it is not uncommon for 
binaries of open source projects to be injected with malware.
-- 
https://mail.python.org/mailman/listinfo/python-list


Python question

2020-03-06 Thread Mr . Lee Chiffre
Thank you Marco for at least taking the time to read my message even if you do 
not agree with me on things. And no disrespect to you. But I came here for 
python related questions and help. Not to be called suspicious and 
untrustworthy only because I am concerned about security of users and for being 
a advocate of privacy. Then to call for me to be censored is just ludicrous.


> People of Python List, I strongly discourage you to support this user.
> He is quite suspicious for the following reasons:
>
> 1. he go so far as he offers money for, IMHO, a trivial task

I said I am a python noob. This is why I asked for help. And I see no issue in 
offering payment for a programming task.

> 2. he does not trust binaries from pip.

What is the point of open source if you cannot compile from source code?

> code. A lack of trust in open source projects that is quite unusual
> 3. I don't trust any cryptocurrency.

Not unusual. People use open source because they dont trust closed source. 
Binaries that someone else compiled is not open source.

> I believe in privacy,  but not in financial privacy. Yes,
> cryptocurrencies can be useful for circumvent bans from tyrannic
> states. But they can, and _are_ used, primarily to:
>  - wash dirty money, by criminals and mafias
>  - evade taxes
>  - buy highly unethical "products", like weapons... and who know what
> other
>  - finance tyrannies.

Roads and cars are used by drug dealers. Stop using roads and cars. Cash is 
used by criminals. Stop using cash. Internet is used by child abusers. Stop 
supporting the internet. I am offended that you group me with criminals and 
baddies because I support technological privacy.


>
> I do _not_ think that all people that uses cryptocurrencies are
> criminals. I had, for example, some co-workers that invested in
> BitCoins, only for profit.
>
> But I do not trust this man, and I hope no one will offer support to
> him. By my side, I'll report this discussion to moderators.

That is fine if you dont like something. You dont have to help me out if you 
dont want to. But trying to censor me is unethical. Hopefully other people will 
have the logic to make decisions for themselves and give me help on python if 
they choose to do so.

I hope my reply does not get censored. I am being reasonable here. And if you 
are wondering why I am "paranoid", you would be too if you are dealing with a 
server that might host a hot wallet. I dont want my server getting hacked just 
because I was too lazy to compile my own code. And it is not uncommon for 
binaries of open source projects to be injected with malware.
-- 
https://mail.python.org/mailman/listinfo/python-list


Python question

2020-03-06 Thread Mr. Lee Chiffre
Thank you Marco for at least taking the time to read my message even if
you do not agree with me on things. And no disrespect to you. But I came
here for python related questions and help. Not to be called suspicious
and untrustworthy only because I am concerned about security of users and
for being a advocate of privacy. Then to call for me to be censored is
just ludicrous.


> People of Python List, I strongly discourage you to support this user.
> He is quite suspicious for the following reasons:
>
> 1. he go so far as he offers money for, IMHO, a trivial task

I said I am a python noob. This is why I asked for help. And I see no
issue in offering payment for a programming task.

> 2. he does not trust binaries from pip.

What is the point of open source if you cannot compile from source code?

> code. A lack of trust in open source projects that is quite unusual
> 3. I don't trust any cryptocurrency.

Not unusual. People use open source because they dont trust closed source.
Binaries that someone else compiled is not open source.

> I believe in privacy,  but not in financial privacy. Yes,
> cryptocurrencies can be useful for circumvent bans from tyrannic
> states. But they can, and _are_ used, primarily to:
>  - wash dirty money, by criminals and mafias
>  - evade taxes
>  - buy highly unethical "products", like weapons... and who know what
> other
>  - finance tyrannies.

Roads and cars are used by drug dealers. Stop using roads and cars. Cash
is used by criminals. Stop using cash. Internet is used by child abusers.
Stop supporting the internet. I am offended that you group me with
criminals and baddies because I support technological privacy.


>
> I do _not_ think that all people that uses cryptocurrencies are
> criminals. I had, for example, some co-workers that invested in
> BitCoins, only for profit.
>
> But I do not trust this man, and I hope no one will offer support to
> him. By my side, I'll report this discussion to moderators.

That is fine if you dont like something. You dont have to help me out if
you dont want to. But trying to censor me is unethical. Hopefully other
people will have the logic to make decisions for themselves and give me
help on python if they choose to do so.

I hope my reply does not get censored. I am being reasonable here. And if
you are wondering why I am "paranoid", you would be too if you are dealing
with a server that might host a hot wallet. I dont want my server getting
hacked just because I was too lazy to compile my own code. And it is not
uncommon for binaries of open source projects to be injected with malware.



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


Re: Help building python application from source

2020-03-02 Thread Mr. Lee Chiffre via Python-list


> I think I have the solution, but can I ask you why are you creating a
> bitcoin server?
>
Yes. I am a crypto anarchist. I have a bitcoin node to do my part to
running the bitcoin network and help remain it decentralized and
resilient. The more people that run a node the better it is. When it comes
to hosting servers I believe I am able to do so in a highly secure manner.
So I am doing my part in secure the bitcoin network and documenting what I
do to help others do the same thing.

I support the bitcoin project because it is a liberty enhancing technology
to counter act over reaching government and expanding tyranny. People have
a right to financial privacy. And the world needs a secure financial
network to replace the existing institutional one that suffers from fraud
and theft.In a cyber dystopian world we live in there is a war on cash
and privacy to push us into a digital monetary system where governments
are able to spy on and control everything and everyone. If there is a need
for digital money let it be one that supports liberty instead of weakening
it. It is vital that cypher tech outpaces the police state. What we do
determines the future. We can let ourselves be enslaved and passive. Or we
can be active and support the solutions that create a better world and
preserve what is good.

Right now it is a full node and not used for any other services or
purposes. If possible I would like to add electrumx so users of the
electrum wallet can use my server. Electrum is a very popular wallet and
is what comes pre installed with TAILS.

-- 
lee.chif...@secmail.pro
PGP 97F0C3AE985A191DA0556BCAA82529E2025BDE35

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


Re: Help building python application from source

2020-02-29 Thread Mr. Lee Chiffre
Thanks for the comments.

> (To make OP's requirements plainly visible, note that this appears to
> be a cryptocurrency application.)

Correct. It is a software that does not store private keys but acts as a
server to serve lightweight wallets that would connect to it remotely.


Electrumx does not store or generate private keys but my concern is
running binary blobs that someone else created. The advantages of open
source software only apply if you can confirm it was created from the
source code. This is why I compile everything I can or use binaries based
on reproducible build process. I am also wanting to run electrumx in a
virtual environment under a dedicated user account on the linux box with
lowest privileges. And the reason I want to be able to build from a local
directory so that I can be self sufficient and be able to archive the
software source code and all needed dependencies to spin up other servers
or replace the server in a post disaster situation where internet or
python pip package servers might be down. My bitcoin server also has very
strict firewall rules that would inhibit the ability to connect to python
servers. This is why I want to download the all the source code on my
laptop then transfer to the server. But there are SO MANY dependencies.
Electrumx has a few dependencies then each of those dependencies have more
dependencies and on and on. I guess it might be possible to do what I want
by manually downloading the source code of the close to 20 dependencies,
manually verify the git tags and signatures. Then "python setup.py
install" each one individually in the right order. This might work? I
didn't know if there was an easier way. I did find out I could "pip
download -r requirements.txt" but this downloads binaries specific for
x86. My cpu architecture is aarch64.

Is there a way to pip download -r requirements.txt source only or specify
aarch64?

Thank you


-- 
lee.chif...@secmail.pro
PGP 97F0C3AE985A191DA0556BCAA82529E2025BDE35

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


Help building python application from source

2020-02-28 Thread Mr. Lee Chiffre
sorry re posting because I forgot subject line in last email.





I am a python noob. This is why I ask the python masters. There is a
python software I want to install on the server it is called Electrumx.
https://github.com/kyuupichan/electrumx is the link. I am having troubles
with installing this.
The short version is I am wanting to build this python application and
needed dependencies from source code all from a local directory without
relying on the python pip package servers. I only run software I can
compile from source code because this is the only way to trust open source
software. I also want to archive the software I use and be able to install
it on systems in a grid down situation without relying on other servers
such as python package servers.

 Here is a snippet from
https://github.com/lee-chiffre/Announcements/blob/master/02.26.2020 that
describes what I am trying to do

>
1. I need a way I can download the source of ElectrumX and the dependency
tree.
2. In a way that also verifies the integrity of those downloads. I dont
think many of these
python packages are even signed.
3. Then to be able to build ElectrumX and the needed dependencies from
source on a computer
that does not have connection to internet. Node2.0 does not connect to
internet except for
the Tor process. Torsocks is not an option here.
I will be running ElectrumX and the python dependencies in a venv virtual
environment.
If I cannot build ElectrumX and the dependencies for it from source in a
way that also verifies
the integrity of the downloads then for security reasons I will not run
it. If someone has a
solution to this I will then run ElectrumX, and give you credit for the help.
If you need me to pay bounty for this please reach out to me to negotiate
on a price.
<


Python might be easy to code but simplicity of coding comes at the cost of
complexity of the software. With C++ I usually only have only a few
dependencies. With python it seems like it is almost 20 dependencies. With
Electrumx I counted at least 15 dependencies in the dependency tree. Is it
possible to download then build this from source with all needed
dependencies?



-- 
lee.chif...@secmail.pro
PGP 97F0C3AE985A191DA0556BCAA82529E2025BDE35


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


Re: Python Resources related with web security

2019-11-26 Thread Mr. Gentooer
On Tue, Nov 26, 2019 at 03:29:48PM -0500, Joel Goldstick wrote:
> On Tue, Nov 26, 2019 at 2:23 PM Mr. Gentooer  wrote:
> >
> > > > On Mon, 25 Nov 2019 21:25:12 + (UTC), Pycode 
> > > > declaimed the following:
> > > >
> > > > comp.lang.python gmane.comp.python.general
> >
> > how do you access these in a reasonable way?
> >
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> 
> I'm thinking this is a troll or a turing machine experiment?

why would I be a troll? I have never used usenet. I am honestly and
genuinely curious.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python Resources related with web security

2019-11-26 Thread Mr. Gentooer
> > On Mon, 25 Nov 2019 21:25:12 + (UTC), Pycode 
> > declaimed the following:
> > 
> > comp.lang.python gmane.comp.python.general

how do you access these in a reasonable way?

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


Re: Your IDE's?

2019-03-27 Thread Mr Zaug
On Monday, March 25, 2019 at 5:38:41 PM UTC-4, John Doe wrote:
> What is your favorite Python IDE?

"Your IDE's?" is not a question, nor is any word in English made plural with an 
apostrophe  s.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Metaclasses - magic functions

2016-12-23 Thread Mr. Wrobel

W dniu 23.12.2016 o 15:14, Ian Kelly pisze:
(...)


cls.added_in_init = 'test'



Man, you are awsome genius! Finally somebody was able to explain me what 
is the power of __new__ and difference between __init__ !!!


So what I wanted to achieve was adding some new attributes to the class 
instances (objects) like this:



#!/usr/bin/env python

class MetaClass(type):
# __init__ manipulation:

def __init__(cls, name, bases, dct):
cls.added_in_init = 'test'
super(MetaClass, cls).__init__(name, bases, dct)

class BaseClass(object):
__metaclass__ = MetaClass

class NewBaseClass(BaseClass):
def __init__(self):
self.inst_attr = self.added_in_init


print("Lets print attributes added in __init__ in base classes:")


b = NewBaseClass()
print(b.added_in_init)

print(b.inst_attr)


And finally it works!

Man I owe you a galaxy of thanks, because I was so frustrated! The 
examples taken from internet never explained me it in so clearly like 
you did!


Really, really thank you!!!
--
https://mail.python.org/mailman/listinfo/python-list


Re: Metaclasses - magic functions

2016-12-23 Thread Mr. Wrobel

W dniu 21.12.2016 o 02:51, Ethan Furman pisze:

On 12/20/2016 03:39 PM, Ben Finney wrote:

"Mr. Wrobel" writes:



Quick question, can anybody tell me when to use __init__ instead of
__new__ in meta programming?


Use β€˜__new__’ to do the work of *creating* one instance from nothing;
allocating the storage, determining the type, etc. β€” anything that will
be *the same* for every instance. β€˜__new__’ is the constructor.

Use β€˜__init__’ to do the work of *configuring* one instance, after it
already exists. Any attributes that are special to an instance should be
manipulated in the β€˜__init__’ method. β€˜__init__’ is the initialiser.


That sounds like general object creation/class advice, which as a general
guideline is okay, but don't feel like it's the most important thing.

I only use `__new__` when the object being created is (or is based on)
an immutable type; otherwise I use `__init__`.  Likewise, if I'm using
`__new__` then I do all my configuration in `__new__` unless I have a
really good reason not to (such as making it easier for subclasses to
modify/skip `__init__`).

As far as metaclasses go... the only time I recall writing an `__init__`
for a metaclass was to strip off the extra arguments so `type.__init__`
wouldn't fail.

--
~Ethan~
Hi,thanx for answers, let's imagine that we want to add one class 
attribute for newly created classess with using __init__ in metaclass, 
here's an example:


#!/usr/bin/env python

class MetaClass(type):
# __init__ manipulation:

def __init__(cls, name, bases, dct):
dct['added_in_init'] = 'test'
super(MetaClass, cls).__init__(name, bases, dct)

class BaseClass(object):
__metaclass__ = MetaClass

class NewBaseClass(BaseClass):
pass

print("Lets print attributes added in __init__ in base classes:")

print(BaseClass.added_in_init)

print(NewBaseClass.added_in_init)

after running it: AttributeError: type object 'BaseClass' has no 
attribute 'added_in_init'


Adding the same in __new__ works. Can anyone explain me please what's wrong?

Cheers,
M



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


Metaclasses - magic functions

2016-12-20 Thread Mr. Wrobel

Hi,

Quick question, can anybody tell me when to use __init__ instead of 
__new__ in meta programming?


I see that __new__ can be used mostly when I want to manipulate with 
class variables that are stored into dictionary.


But when to use __init__? Any example?

Thanx,
M
--
https://mail.python.org/mailman/listinfo/python-list


Re: [Theory] How to speed up python code execution / pypy vs GPU

2016-11-05 Thread Mr. Wrobel

W dniu 05.11.2016 o 22:17, Ben Bacarisse pisze:

Steve D'Aprano  writes:


On Sun, 6 Nov 2016 04:10 am, Mr. Wrobel wrote:


Hi,

Some skeptics asked my why there is a reason to use Python against of
any other "not interpreted" languages, like objective-C.


Here's the "Hello World" program in Python:

--- cut ---

print("Hello World")

--- cut ---



Here's the same program in Objective C:

--- cut ---

#import 

int main (int argc, const char * argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSLog (@"Hello, World!");
[pool drain];
return 0;
}

--- cut ---

Which would you rather write?


That's a rather odd comparison.  Why not

  #import 

  int main()
  {
printf("Hello world\n");
return 0;
  }

?  It's decades since I wrote any Objective-C (and then not much) but I
think this is the closest comparison.


Wel, indeed. However the most important is second part of my question.

What do you think about using GPU processing or pypy?
--
https://mail.python.org/mailman/listinfo/python-list


[Theory] How to speed up python code execution / pypy vs GPU

2016-11-05 Thread Mr. Wrobel

Hi,

Some skeptics asked my why there is a reason to use Python against of 
any other "not interpreted" languages, like objective-C. As my 
explanation, I have answered that there is a a lot of useful APIs, 
language is modern, has advanced objective architecture, and what is the 
most important - it is  dynamic and support is simply great.


However the same skeptics told my that, ok we believe that it is true, 
however the code execution is much slower than any other compiled language.


I must tell you that is the reason I started to dig into internet and 
searching some methods to speed up python's code.


1. What I have found is modified python interpreter - pypy  - 
http://pypy.org that does not require any different approach to develop 
your code.


2. And: Gpu based computing powered by Nvidia (NumbaPro compiler): 
https://developer.nvidia.com/how-to-cuda-python


Do you have any experience in that areas, and maybe some benchmarks 
showing advantage of using these technologies?


Cheers,
Marcin
--
https://mail.python.org/mailman/listinfo/python-list


Re: Meta classes - real example

2016-10-20 Thread Mr. Wrobel

W dniu 18.10.2016 o 16:42, Ethan Furman pisze:

On 10/17/2016 11:44 PM, Mr. Wrobel wrote:


Ok,so in general, we could say that using Metclasses is ok for
manipulating __new__ but not that what is setting by __init__. Am I
right?


No and yes.

In this code (python 2 syntax):

#untested
class Wonderful(object):

__metaclass__ = SomeMetaClass
diamond = Sparkly(7)
club = 9

def display(self):
print "I'm an instance!"

The metaclass controls what happens when Wonderful is created:

- it can add the name 'diamond' to the Sparkly descriptor;
-  it can change/remove/add other attributes such as club, spade, or
whatever;
- it can wrap methods such as display to pre- or post-process calls to it
- etc.

Once the class (Wonderful, in this example) has been created:

- x = Wonderful()  # metaclass not called
- x.display()  # metaclass not called
- x.diamond# metaclass not called

- list(Wonderful)  # metaclass called (e.g. SomeMetaClass.__iter__(cls) )
   # where cls = Wonderful


Check out http://stackoverflow.com/a/35730545/208880 for a simple
demonstration of a metaclass.

--
~Ethan~

Thank you Ethan!
--
https://mail.python.org/mailman/listinfo/python-list


Re: Meta classes - real example

2016-10-17 Thread Mr. Wrobel

W dniu 17.10.2016 o 23:23, Ethan Furman pisze:

On 10/17/2016 09:23 AM, Mr. Wrobel wrote:

W dniu 17.10.2016 o 18:16, Chris Angelico pisze:

On Tue, Oct 18, 2016 at 3:03 AM, Mr. Wrobel wrote:



I am looking for an example of metaclass usage. Especially I am
interestet
in manipulating instance variables, for example:

My class:
class MrMeta(type):
pass

class Mr(object):
__metaclass__ = MrMeta

def __init__(self):
self.imvariable = 'Zmienna self'

def aome method(self):
print 'I am in instance'

So in general, I would like to create a mechanism, that is changing
value
for self.imvariable to capital letters and this should be included
in my
metaclass called MrMeta(type).

Can you guide me please?


Are you sure you can't just use a descriptor, such as @property?

class Mr(object):
@property
def imvariable(self):
return self._imvariable
@imvariable.setter
def imvariable(self, value):
self._imvariable = str(value).upper()


I am sure that I can do that with setter/getter, but I want to be
closer to black magic, that is why I wanted to inlcude Metaclasses.

I know how to acomplish that for class variables, but don;t have any
idea how to instance.


Metaclasses work on the class level, not the instance level.  The only*
influnce a metaclass is going to have on instances is changes it makes
while it's creating the class.

For example, MrMeta could set descriptors in Mr when it is creating the
Mr class; it could even put it's own __init__ in the class; but to
affect things like instance variables that are added in methods -- well,
it is possible, but it is *a lot* of work.

--
~Ethan~

* Okay, somebody prove me wrong!  :)


Ok,so in general, we could say that using Metclasses is ok for 
manipulating __new__ but not that what is setting by __init__. Am I right?


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


Re: Meta classes - real example

2016-10-17 Thread Mr. Wrobel

W dniu 17.10.2016 o 18:16, Chris Angelico pisze:

On Tue, Oct 18, 2016 at 3:03 AM, Mr. Wrobel  wrote:

Hi,

I am looking for an example of metaclass usage. Especially I am interestet
in manipulating instance variables, for example:

My class:
class MrMeta(type):
pass

class Mr(object):
__metaclass__ = MrMeta

def __init__(self):
self.imvariable = 'Zmienna self'

def aome method(self):
print 'I am in instance'

So in general, I would like to create a mechanism, that is changing value
for self.imvariable to capital letters and this should be included in my
metaclass called MrMeta(type).

Can you guide me please?


Are you sure you can't just use a descriptor, such as @property?

class Mr(object):
@property
def imvariable(self):
return self._imvariable
@imvariable.setter
def imvariable(self, value):
self._imvariable = str(value).upper()

ChrisA


Hi,

I am sure that I can do that with setter/getter, but I want to be closer 
to black magic, that is why I wanted to inlcude Metaclasses.


I know how to acomplish that for class variables, but don;t have any 
idea how to instance.


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


Meta classes - real example

2016-10-17 Thread Mr. Wrobel

Hi,

I am looking for an example of metaclass usage. Especially I am 
interestet in manipulating instance variables, for example:


My class:
class MrMeta(type):
pass

class Mr(object):
__metaclass__ = MrMeta

def __init__(self):
self.imvariable = 'Zmienna self'

def aome method(self):
print 'I am in instance'

So in general, I would like to create a mechanism, that is changing 
value for self.imvariable to capital letters and this should be included 
in my metaclass called MrMeta(type).


Can you guide me please?

Thanks!
Mr. Wrobel
--
https://mail.python.org/mailman/listinfo/python-list


Re: How to process syntax errors

2016-10-12 Thread mr . puneet . goyal
On Monday, October 10, 2016 at 7:45:40 PM UTC+5:30, mr.pune...@gmail.com wrote:
> Hi 
> 
> Is there any way to capture syntax errors and process them ? I want to write 
> a function which calls every time whenever there is syntax error in the 
> program.
> 
> For example, 
> 
> inside example.py 
> 
> I just mention below line 
> 
> 
> Obj = myClass()
> Obj xyz
> 
> Obj is instance of a class. But there is syntax error on xyz. So I want to 
> grab that error and process.
> 
> Regards, Puneet

Steve, You are absolutely right. I am trying to eliminate the method of using 
parenthesis while calling in my file. Especially when I call it from a instance.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to process syntax errors

2016-10-12 Thread mr . puneet . goyal
Hi All

Its really good to see that some discussion happening around this topic. Sorry 
I was out from my work for sometime so couldn't follow up but I really find it 
useful. It gives me good opportunity to know python better as I recently 
started learning python. 

Ok so I tell you why I need to catch syntax error during compilation and 
process them. See below example, 

# I created a platform class with different method in a file and making it as a 
package. 
class platform:
def connect(self):
# connect device 
def destroy(self):
# destroy device
def config(self, command):
# Send command to configure device
def show(self, command):
# check device health

Now person who wants to write a script using above package can simply use below 
approach. Which does not make him to have knowledge in python. 

DUT = platform()
DUT connect
DUT config {commands}
DUT show {commands}
DUT destroy


But I know this is not easy to do in python. As they all invalid syntax for 
python language. So I thought of grabing syntax errors and manipulate them as 
below internally to call them while code is compiling. 

DUT = platform()
DUT.connect()
DUT.config(commands)
DUT.show(commands)
DUT.destroy()

Hope you understand my need of doing this. If there is another solution to 
achieve what I am trying to. Please let me know. 

Thanks, Puneet
-- 
https://mail.python.org/mailman/listinfo/python-list


How to process syntax errors

2016-10-10 Thread mr . puneet . goyal
Hi 

Is there any way to capture syntax errors and process them ? I want to write a 
function which calls every time whenever there is syntax error in the program.

For example, 

inside example.py 

I just mention below line 


Obj = myClass()
Obj xyz

Obj is instance of a class. But there is syntax error on xyz. So I want to grab 
that error and process.

Regards, Puneet 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: A newbie doubt on methods/functions calling

2016-10-06 Thread mr . puneet . goyal
Let me rephrase my question in other way. 

class myClass:
def __init__(self, var):
self.var = var

myObj = myClass(abc)


# I am calling instance with function name and arguments
myObj func1 arg1 arg2 


Can i associate any function like __init__ with instance ? Means if I just use 
instance anywhere as above, it calls that function in the class and take 
everything as argument which I mentioned after instance? Something like below 

class myClass:
  def __call__(self, args):
# Then I parse the args here and call function internally 
self.func1(arg1, arg2)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: A newbie doubt on methods/functions calling

2016-10-06 Thread mr . puneet . goyal
Well I jump from TCL to Python. And found that it was very convenient to use 
Procs there. So I was looking for that luxury in Python. 

I am not trying to reinvent the wheel. I was just curious to know if there is 
any possibility to create a caller function in  my way (TCL) where I can call 
python function/proc inside myProc. 

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


A newbie doubt on methods/functions calling

2016-10-06 Thread mr . puneet . goyal
Hi 

I just started learning python. Is there any way to call functions in different 
way ?

Rather calling obj.function(arg1, arg2) I would like to call like below 

"obj function arg1 arg2" 

this function is part of a class.

class myClass:
def function(arg1, arg2):
 # do something

Is it possible to do in python ? May be not directly but using some other 
methods. 

Regards, Puneet
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Looking for the best way to make this

2016-10-05 Thread mr . marydavid
Here is another example 
http://www.codetwo.com/media/images/exchange-sync-screencast-5.jpg 
-- 
https://mail.python.org/mailman/listinfo/python-list


Looking for the best way to make this

2016-10-05 Thread mr . marydavid
http://www.qualicode.com/EN/images/ScheduleGrid.png

looking to add schedule like that to my software trying with Qt but not sure 
how to .

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


Re: Generate config file from template using Python search and replace.

2015-12-01 Thread Mr Zaug
Ye, this does work. Many thanks!

filename = "{NNN}_{BRAND}_farm.any".format(BRAND=brand, NNN=nnn)
with open(filename, "w") as outstream:
outstream.write(data)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Generate config file from template using Python search and replace.

2015-12-01 Thread Mr Zaug
That makes sense. 

So I still can't see how to write the string object to a file whist naming the 
file with whatever values I provided for the NNN and BRAND variables.

Printing the contents of the string object is working with all the expected 
substitutions. Do I need to convert the string object into a file before I 
write it? Or do I need to open a new file and somehow stuff the string object 
into it?

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


Re: Generate config file from template using Python search and replace.

2015-12-01 Thread Mr Zaug
Actually, I don't understand what you mean by "all other braces." What braces 
are you talking about? The placeholders in the template file (the file being 
read in) have braces around them but they are not escaped. 

Also, do I really need curly braces to tell Python what my placeholders are?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Generate config file from template using Python search and replace.

2015-12-01 Thread Mr Zaug
Oh, that's much easier to read. Thanks!


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


Re: Generate config file from template using Python search and replace.

2015-11-30 Thread Mr Zaug
On Monday, November 30, 2015 at 4:14:48 AM UTC-5, Peter Otten wrote:
> Mr Zaug wrote:
> 
> > On Sunday, November 29, 2015 at 5:50:51 PM UTC-5, Peter Otten wrote:
> >> Mr Zaug wrote:
> >> 
> >> > When I run this script on OS X El Capitan, I see,
> >> >   
> >> >   # permission sensitive cache
> >> >   $include "_dispatcher_shared_auth-checker:
> >> > 
> >> > Was I supposed to incorporate it into the script I posted?
> >> 
> >> Are you referring to my post? I'm sorry, I can't make sense of your
> >> question.
> > 
> > Yes. The snippet you posted went way over my head. When I ran it, it
> > printed
> > 
> > # permission sensitive cache
> >   $include "_dispatcher_shared_auth-checker:
> 
> It's hard to tell from that problem description what might have gone wrong. 
> However:
> 
> In your template file you have to enclose all words you want to replace in 
> braces ("you have foo options" becomes "you have {foo} options"), to replace 
> all literal { with {{ and all literal } with }}.
> 
> Did you do that?

Yup, I sure did. So here is my current script. The only remaining task now is 
figuring out how to write the contents to a new file.

#!/usr/bin/env python
import os
import sys

script, template_file = sys.argv
print "Opening the template file..."

print "What is the serial number of the site?",
nnn = raw_input()

print "What is the brand, or product name?",
brand = raw_input()

print "What is the (fqdn) ServerName?",
server_name = raw_input()

print "What is the content path?",
content_path = raw_input()

print "What is the DAM path?",
dampath = raw_input()

print "Which environment is this for?",
env = raw_input()

print "What is the cache document root?",
cache_docroot = raw_input()

with open (template_file, "r") as a_string:
data=a_string.read().replace('{SERVER_NAME}', 
server_name).replace('{BRAND}', brand).replace('{CONTENT_PATH}', 
content_path).replace('{DAMPATH}', dampath).replace('{ENV}', 
env).replace('{CACHE_DOCROOT}', cache_docroot)

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


Re: Generate config file from template using Python search and replace.

2015-11-29 Thread Mr Zaug
On Sunday, November 29, 2015 at 5:50:51 PM UTC-5, Peter Otten wrote:
> Mr Zaug wrote:
> 
> > When I run this script on OS X El Capitan, I see,
> >   
> >   # permission sensitive cache
> >   $include "_dispatcher_shared_auth-checker:
> > 
> > Was I supposed to incorporate it into the script I posted?
> 
> Are you referring to my post? I'm sorry, I can't make sense of your 
> question.

I seem to be heading in this direction.

#!/usr/bin/env python
import re
from os.path import exists

script, template_file = argv
print "Opening the template file..."

with open (template_file, "r") as a_string:
data=a_string.read().replace('BRAND', 'Fluxotine')
print(data)

So now the challenge is to use the read().replace magic for multiple values.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Generate config file from template using Python search and replace.

2015-11-29 Thread Mr Zaug
On Sunday, November 29, 2015 at 5:50:51 PM UTC-5, Peter Otten wrote:
> Mr Zaug wrote:
> 
> > When I run this script on OS X El Capitan, I see,
> >   
> >   # permission sensitive cache
> >   $include "_dispatcher_shared_auth-checker:
> > 
> > Was I supposed to incorporate it into the script I posted?
> 
> Are you referring to my post? I'm sorry, I can't make sense of your 
> question.

Yes. The snippet you posted went way over my head. When I ran it, it printed 

# permission sensitive cache 
  $include "_dispatcher_shared_auth-checker: 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: I can't understand re.sub

2015-11-29 Thread Mr Zaug
On Sunday, November 29, 2015 at 8:12:25 PM UTC-5, Rick Johnson wrote:
> On Sunday, November 29, 2015 at 3:37:34 PM UTC-6, Mr Zaug wrote:
> 
> > The items I'm searching for are few and they do not change. They are 
> > "CONTENT_PATH", "ENV" and "NNN". These appear on a few lines in a template 
> > file. They do not appear together on any line and they only appear once on 
> > each line. This should be simple, right?
> 
> Yes. In fact so simple that string methods and a "for loop" will suffice. 
> Using regexps for this tasks would be like using a dump truck to haul a 
> teaspoon of salt.

I rarely get a chance to do any scripting so yeah, I stink at it.

Ideally I would have a script that will spit out a config file such as 
087_pre-prod_snakeoil_farm.any and not need to manually rename said output file.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: I can't understand re.sub

2015-11-29 Thread Mr Zaug
Thanks. That does help quite a lot.
-- 
https://mail.python.org/mailman/listinfo/python-list


I can't understand re.sub

2015-11-29 Thread Mr Zaug
I need to use re.sub to replace strings in a text file. I can't seem to 
understand how to use the re module to this end.

result = re.sub(pattern, repl, string, count=0, flags=0);

I think I understand that pattern is the regex I'm searching for and repl is 
the thing I want to substitute for whatever pattern finds but what is string?

The items I'm searching for are few and they do not change. They are 
"CONTENT_PATH", "ENV" and "NNN". These appear on a few lines in a template 
file. They do not appear together on any line and they only appear once on each 
line.

This should be simple, right?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Generate config file from template using Python search and replace.

2015-11-29 Thread Mr Zaug
When I run this script on OS X El Capitan, I see,
  
  # permission sensitive cache
  $include "_dispatcher_shared_auth-checker: 

Was I supposed to incorporate it into the script I posted?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Generate config file from template using Python search and replace.

2015-11-28 Thread Mr Zaug
I should mention the template file is small, just 98 lines long and the working 
config file will be the same size.
-- 
https://mail.python.org/mailman/listinfo/python-list


Generate config file from template using Python search and replace.

2015-11-28 Thread Mr Zaug
I need to generate a config file based on an existing "template" file. I need 
to replace a set of strings with other strings globally in the generated file.

Here is a snippet of the template file, where CONTENT_PATH and DAMPATH are two 
"placeholders" or variables. There are several other such placeholders.

  $include "_dispatcher_publish_filters.any"
  /1000 { /type "allow"  /glob "* /CONTENT_PATH/*.html*" }
  /1001 { /type "allow"  /glob "POST /DAMPATH/www/*.html *" }

The script's user will be asked to type in unique values when prompted for 
DAMPATH or CONTENT_PATH.

Since I know the variables themselves are not going to change (because the 
contents of the template file don't spontaneously change) should I be using 
regex to search for them or is there a better way? I was planning on using 
re.sub but I don't know whether that's the best way. Here's what my script 
looks like today.

from sys import argv
import re
from os.path import exists

script, template_file = argv
print "Opening the template file..."

in_file = open(template_file)
lines = in_file.readlines()

print "What is the serial number of the site?",
_NNN = raw_input()

print "What is the brand, or product name?",
_BRAND = raw_input()

print "What is the content path?",
_CONTENT_PATH = raw_input()

out_file = open(_nnn + _brand + "_farm.any", 'w')

for line in lines:
   re.sub('NNN', _NNN, line)
   re.sub('BRAND, _BRAND', line)
   re.sub('CONTENT_PATH', _CONTENT_PATH, line)

out_file.close()
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Sudoku solver

2015-03-29 Thread mr . smittye
On Wednesday, March 25, 2015 at 4:39:40 AM UTC-7, Marko Rauhamaa wrote:
> A lot of discussion was generated by the good, old fibonacci sequence. I
> have yet to find practical use for fibonacci numbers. However, the
> technique behind a sudoku solver come up every now and again in
> practical situations.
> 
> I post below a sudoku solver. I eagerly await neater implementations (as
> well as bug reports).
> 
> Usage:
> 
> ./sudoku.py  
> 
> sudoku.dat:
> 
> 7 . . . . . 6 . .
> . 2 . 8 . 6 . 7 .
> . . . 4 3 . . 9 .
> 5 1 . . . . 4 . 3
> . . 9 . . . . 1 .
> . . . . 4 2 . . 5
> . . . 9 . . . . 8
> . . 6 . . . . 5 .
> . . . . . . . 6 .
> 
> 
> output:
> 
> 7 8 4 2 9 5 6 3 1
> 9 2 3 8 1 6 5 7 4
> 6 5 1 4 3 7 8 9 2
> 5 1 8 6 7 9 4 2 3
> 2 4 9 3 5 8 7 1 6
> 3 6 7 1 4 2 9 8 5
> 1 7 5 9 6 3 2 4 8
> 8 3 6 7 2 4 1 5 9
> 4 9 2 5 8 1 3 6 7
> 
> 
> 
> sudoku.py:
> 
> #!/usr/bin/env python3
> 
> import sys
> 
> M = 3
> N = M * M
> Q = N * N
> 
> candidates = list(range(1, N + 1))
> 
> def main():
> board = []
> for n in sys.stdin.read().split():
> try:
> board.append(int(n))
> except ValueError:
> board.append(None)
> solve(board)
> 
> def solve(board, slot=0):
> if slot == Q:
> report(board)
> elif board[slot] is None:
> for candidate in candidates:
> if good(board, slot, candidate):
> board[slot] = candidate
> solve(board, slot + 1)
> board[slot] = None
> else:
> solve(board, slot + 1)
> 
> def good(board, slot, candidate):
> (shelf, row), (stack, col) = (divmod(x, M) for x in divmod(slot, N))
> for i in range(M):
> for j in range(M):
> if candidate in (board[(i * M + j) * N + stack * M + col],
>  board[(shelf * M + row) * N + i * M + j],
>  board[(shelf * M + i) * N + stack * M + j]):
> return False
> return True
> 
> def report(board):
> print("\n".join(
> " ".join(str(board[row * N + col])
>  for col in range(N))
> for row in range(N)))
> print()
> 
> if __name__ == '__main__':
> main()
> 
> 
> 
> Marko

You say "neater implementation"
I'll send you to the code-golf site: 
http://codegolf.stackexchange.com/a/446/38632 this is brute force. There are 
some really good implementations in other languages that arent brute force. 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: numpy array product driving me mad

2015-03-20 Thread Mr. Twister
>> I think that you want 
>>
>> P * R[;,None]
> 
> Sorry, I meant 
> 
> P * R[:, None]
> 
> Manolo

MuchΓ­simas gracias, Manolo. Eres un genio y me has ayudado mucho. Te debo una.
-- 
https://mail.python.org/mailman/listinfo/python-list


numpy array product driving me mad

2015-03-20 Thread Mr. Twister
Hi everyone.

Hope you can help me overcome this "noob" issue.

I have two numpy arrays:

>>> P
array([[[ 2,  3],
[33, 44],
[22, 11],
[ 1,  2]]])
>>> R
array([0, 1, 2, 3])

the values of these may of course be different. The important fact is that:

>>> P.shape
(1, 4, 2)
>>> R.shape
(4,)

where the number 4 in the shape of both P and R may be another number as well
(same on both).


What I'd like to get is a new array Q with same shape as P so that the nth pair
of Q is the nth pair of P multiplied by the nth element of R. I.e., in the above
case it should produce:

>>> Q
array([[[ 0,  0],
[33, 44],
[44, 22],
[ 3,  6]]])


Is there a direct, single expression command to get this result? I have tried
all I could imagine, including .T, extend_dims, h/vstack, repeat..., so far with
no success.

Please, any help will be welcomed.

Thanks.

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


Re: Can I trust downloading Python?

2013-09-11 Thread Mr. Roboto
On Saturday, September 7, 2013 9:17:46 PM UTC-4, Aaron Martin wrote:
> Hi, I am thinking about getting a software but it requires python, so that 
> brought up a few questions. Is it safe do download python, and does it come 
> with spam or advertisements? If it doesn't then should I get the latest 
> version? I mostly want to know if it is safeΒ to download, because most of the 
> timeΒ downloading free stuff off the internet comes withΒ spam and all that, so 
> I want to know if I can trust downloading it.

Hope others find this article helpful and relevant:

http://www.eweek.com/developer/open-source-python-code-sets-new-standard-for-quality-study.html/?kc=EWKNLEAU09102013BESTOF2&dni=77668545&rni=22939981

A development testing company (Coverity) reports that the core Python platform 
has a very low number of source code defects and its developers effect repairs 
to known flaws very readily, as compared to other open-source projects.  I 
can't attest to the validity of the claim (one way or the other), but it is 
something worth noting
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Debugging difficulty in python with __getattr__, decorated properties and AttributeError.

2013-05-15 Thread Mr. Joe
On Wed, May 15, 2013 at 12:15 PM, dieter  wrote:
>
>   If Python would automatically redecorate overridden methods in a derived
>   class, I would have no control over the process. What if I need
>   the undecorated method or a differently decorated method (an
>   uncached or differently cached method, in my case)?
>

On a second thought, I am convinced by your argument.

> Your getter/setter use case can quite easily be solved
> with a class "DelayedMethodAccessor":
>
>   class DelayedMethodAccess(object):
> """
> def __init__(self, name): self.__name = name
> def __call__(self, inst, *args, **kw):
>   return getattr(inst, self.__name)(*args, **kw)
>
> You can then use:
>
>prop = property(DelayedMethodAccess(""), ...)
>
> Or define a new decorator "property_by_name" and then
> use
>
>prop = property_by_name("", ...)
>
> Of course, this requires that the property name and the getter/setter
names
> differ, but this should be naturally enough.
>
>
> Python's current behavior is very natural once you know that
> decorators are just syntactic sugar and
>
>@
>def ...
>
> simply means:
>
>def ...
>f = (f)
>
> True, this is no perfect fit for all use cases - but
> such a fit (if it existed at all) would have to be so complex
> that only experts could understand it.

Thanks for these really nice patterns. They fits my problem very well.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Debugging difficulty in python with __getattr__, decorated properties and AttributeError.

2013-05-14 Thread Mr. Joe
Sorry for digging this old topic back. I see that my "'property' does not
play well with polymorphic code" comment generated some controversy. So
here's something in my defense:

Here's the link to stackoveflow topic I am talking about:

http://stackoverflow.com/questions/237432/python-properties-and-inheritance

The solution that fits my taste:
http://stackoverflow.com/a/14349742

A related blogpost:

http://requires-thinking.blogspot.com/2006/03/note-to-self-python-properties-are-non.html

Yes, I like decorators and descriptors. I also like the ability to create a
"virtual property" in a python class by binding a bunch of methods as
setter/getter. But I find the implementation of this "virtual property
feature" a bit awkward sometimes - every time I need to override a
getter/setter in a child class, I need to decorate them again. Some of you
may like this "explicitness", but I don't.

To Steven D'Aprano: Seriously, what's all the bashing in your last reply
about? You dissected my "thank-you reply" more strictly than the python
interpreter checking for syntax errors. Not in a mood for fight, but I find
your opinions about "bug finding time", "hacks" and "stackoverflow" quite
silly.
-- 
http://mail.python.org/mailman/listinfo/python-list


Differences of "!=" operator behavior in python3 and python2 [ bug? ]

2013-05-12 Thread Mr. Joe
I seem to stumble upon a situation where "!=" operator misbehaves in
python2.x. Not sure if it's my misunderstanding or a bug in python
implementation. Here's a demo code to reproduce the behavior -
"""
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, print_function

class DemoClass(object):
def __init__(self, val):
self.val = val

def __eq__(self, other):
return self.val == other.val

x = DemoClass('a')
y = DemoClass('a')

print("x == y: {0}".format(x == y))
print("x != y: {0}".format(x != y))
print("not x == y: {0}".format(not x == y))
"""

In python3, the output is as expected:
"""
x == y: True
x != y: False
not x == y: False
"""

In python2.7.3, the output is:
"""
x == y: True
x != y: True
not x == y: False
"""
Which is not correct!!

Thanks in advance for clarifications.
Regards,
TB
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Debugging difficulty in python with __getattr__, decorated properties and AttributeError.

2013-05-03 Thread Mr. Joe
Thanks for clearing up. Developers of python should address this issue, in
my opinion. 3.4/3.5 maybe, but better late than never.

Recently, I've been beaten back for using some exotic features of python.
One is this[ Took me hours to get to the bottom ]. The other one is
'property' decorator. I was using it extensively until I needed to make a
child class. Then I came to know that 'property' does not play well
with polymorphic code. :( I resorted to some lambda hacks learned from
stackoverflow.com to solve the problem. I know that it's the correct way
for decorators to work, but still, it would be nice to have a language
level solution.
-- 
http://mail.python.org/mailman/listinfo/python-list


Debugging difficulty in python with __getattr__, decorated properties and AttributeError.

2013-05-02 Thread Mr. Joe
Is there any way to raise the original exception that made the call to
__getattr__? I seem to stumble upon a problem where multi-layered attribute
failure gets obscured due to use of __getattr__. Here's a dummy code to
demonstrate my problems:
"""
import traceback


class BackupAlphabet(object):
pass


class Alphabet(object):
@property
def a(self):
return backupalphabet.a


def __getattr__(self, name):
if name == "b":
return "banana"

raise AttributeError(
"'{0} object has no attribute '{1}'"
.format(self.__class__.__name__, name))


alphabet = Alphabet()
backupalphabet = BackupAlphabet()

print(alphabet.a)
print(alphabet.b)
"""

Running the above code produces this:
"""
Traceback (most recent call last):
  File "example.py", line 26, in 
print(alphabet.a)
  File "example.py", line 20, in __getattr__
.format(self.__class__.__name__, name))
AttributeError: 'Alphabet object has no attribute 'a'
"""

While it's easy enough to identify the problem here, the traceback is
rather unhelpful in complex situations. Any comments?

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


How do I use PyGTK to put text besides clickable buttons?

2012-04-02 Thread Jason Hsu, Mr. Swift Linux
I've decided to use PyGTK instead of gtkdialog for providing
configuration menus/dialog boxes in Swift Linux, the Linux distro I
started.  The problem with gtkdialog is that the i386 version is no
longer available in the Debian repository.

Since a picture is worth a thousand words, I'll give you a link to a
screenshot of antiX Linux:
http://antix.freeforums.org/download/file.php?id=23

How do I use PyGTK to create something similar to the logout dialog
box in the above graphic?  I've figured out how to create clickable
buttons that each run a different script.  What I haven't figured out
is how to add text beside each button.
-- 
http://mail.python.org/mailman/listinfo/python-list


Can I fully replace GNU Bash with Python?

2011-11-04 Thread Jason Hsu, Mr. Swift Linux
This question concerns my process of creating Swift Linux from the
base distro (antiX Linux in the past, Linux Mint Debian Edition now).
(NOTE: The process I'm describing here is an oversimplification.)

All of my development work takes place in the ~/develop directory.
This is the directory where I enter the "git clone" command to
download the repositories from GitHub.  These repositories are 1-
build, majorfunction1, majorfunction2, and so on.  After I download
these repositories, I have the directories ~/develop/1-build, ~/
develop/majorfunction1, ~/develop/majorfunction2, and so on.

The ~/develop/1-build directory contains the scripts that build Swift
Linux.  Each major function needed to create Swift Linux (such as
changing web browser configuration files, changing login manager
configuration files, etc.) has its own majorfunction# repository.

For developing the latest version of Swift Linux, I had the swift.sh
script in the  ~/develop/1-build directory call scripts in the
majorfunction directories with commands like:
sh ~/develop/majorfunction1/main.sh
sh ~/develop/majorfunction2/main.sh
and so on

Please note that one can run any of these major functions
independently OR as part of the ~/develop/1-build/swift.sh script.
The ability to run any major function independently means I can focus
on just one function that's not working as it should WITHOUT messing
around with other functions.  This ability will be especially
important when I have an actual team working on Swift Linux.

What I'd like to do is replace GNU Bash with Python.  I know I can
replace the main.sh scripts with main.py scripts.  Then the commands
in the swift.sh script would be:
python ~/develop/majorfunction1/main.py
python ~/develop/majorfunction2/main.py
and so on

Is there a way I can replace the ~/develop/1-build/swift.sh script
with a ~/develop/1-build/swift.py script, yet still retain the ability
to work on one major function WITHOUT requiring the other major
functions and the 1-build directory to be present?
-- 
http://mail.python.org/mailman/listinfo/python-list


Learning to use decorators with classes

2009-06-30 Thread Mr SZ

Hi,

I'm writing an LDAP plugin for my TG2 application. In this I wrote a small 
class based decorator with args to set up a connection and call the necessary
functionality but I'm having problems with it. Here's my code:

class getConnection(object):

def __init__(self, settings, credentials):
self.settings = settings
self.credentials = credentials

def __call__(self, f):
def wrapped_f(*args, **kw):
...code snipped...
try:
if tls:
connection.start_tls_s()
if anon:
con.simple_bind_s()
else:
con.simple_bind_s( dn, pw )
except ldap.LDAPError, e:
print e.message['info']
else:
kw['conn'] = connection
try:
f(*args, **kw)
except Exception, e:
print 'Exception in Plugin execution: %s' % e
finally:
connection.unbind()

return wrapped_f


class LdapPlugin(Plugin):
...
def __init__(self, **kw):
Plugin.__init__(self)

@getConnection(self._settings, self.__cred__)
def search(self, **kw):
print 'Searching'
...


Here the base class constructor(Plugin) fetches plugin specific settings from 
the web framework and stores it in self._settings and user info in 
self.__cred__ . Now when the method is invoked, this is the error I get:


File '.../plugins/ldap/ldap/__init__.py', line 69 in LdapPlugin
  @getConnection(self._settings, self.__cred__)
NameError: name 'self' is not defined



I can simply write a method that gets a connection and deal with it but I 
wanted to know and learn why decorators is not working in this case.

Regards,
SZ


" life isn't heavy enough,it flies away and floats far above action"


  Access Yahoo!7 Mail on your mobile. Anytime. Anywhere.
Show me how: http://au.mobile.yahoo.com/mail
-- 
http://mail.python.org/mailman/listinfo/python-list


Find the name of a setup tools plugin when its class is known.

2009-06-29 Thread Mr SZ

Hi,

Using pkg_resources, I can iterate through the plugins in an entrypoint and 
note down the plugin classes and all using 
"pkg_resources.iter_entry_points(ENTRYPOINT)"

Now, when the plugin is loaded, I want to know it's entrypoint name as I have 
to load a bunch of settings identified by the name string.


Regards,
SZ


" life isn't heavy enough,it flies away and floats far above action"


  Access Yahoo!7 Mail on your mobile. Anytime. Anywhere.
Show me how: http://au.mobile.yahoo.com/mail
-- 
http://mail.python.org/mailman/listinfo/python-list


getattr on a function

2009-04-27 Thread Mr SZ

Hi all,

Is it possible to call functions using getattr. I have written a simple script 
with functions that call either SSL, TLS or plain functionality.

something like:
def func():
  ...

def funcSSL():
  ...

def funcTLS():
  ...

Now, based on my args I would like to call either one of them. In my case, I 
can't seem to figure out what my object would be when I call getattr(object, 
'func'+) !

" life isn't heavy enough,it flies away and floats far above action"


  Enjoy a safer web experience. Upgrade to the new Internet Explorer 8 
optimised for Yahoo!7. Get it now.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Emulate a printf() C-statement in Python???

2009-03-19 Thread Mr. Z
"Andrii V. Mishkovskyi"  wrote in message
news:mailman.2185.1237467269.11746.python-l...@python.org...
On Thu, Mar 19, 2009 at 2:43 PM, Mr. Z  wrote:
> I'm trying emulate a printf() c statement that does, for example
>
> char* name="Chris";
> int age=30;
> printf("My name is %s", name);
> printf("My name is %s and I am %d years old.", %s, %d);
>
> In other words, printf() has a variable arguement list the we
> all know.
>
> I'm trying to do this in Python...
>
> class MyPrintf(object):
> # blah, blah
> def myprintf(object, *arg):
> # Here I'll have to know I NEED 2 arguments in format string
> arg[0]
> print arg[0] % (arg[1], arg[2])

Note: you can, of course, use any name for the instance variable in
methods, but 'self' is considered a de-facto standard, not 'object'.
Besides, you're overriding builtin which is considered a bad practice.

>
> name="Chris"
> age=30
> printf=MyPrintf()
> printf.myPrintf(("My name is %s and I am %d years old.", name, age)
> will of course print...
> My name is Chris and I am 42 years old.
>
> But
> printf.myPrintf(("My name is %s.", name)
> of course gives
> Index error: list index out of range
>
> How can I generalize the print call in the myprintf() function to do this?
>
> print arg[0] % (arg[1])
> print arg[0] % (arg[1], arg[2])
> print arg[0] % (arg[1], ..., arg[n])

It's quite simple:
def printf(fmt, *args):
print fmt % args

>
> --
>
> ---
> Remove XSPAM
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>

Too simple, I love it!

-- 
Wbr, Andrii V. Mishkovskyi.

He's got a heart of a little child, and he keeps it in a jar on his desk.


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


Emulate a printf() C-statement in Python???

2009-03-19 Thread Mr. Z
I'm trying emulate a printf() c statement that does, for example

char* name="Chris";
int age=30;
printf("My name is %s", name);
printf("My name is %s and I am %d years old.", %s, %d);

In other words, printf() has a variable arguement list the we
all know.

I'm trying to do this in Python...

class MyPrintf(object):
# blah, blah
 def myprintf(object, *arg):
  # Here I'll have to know I NEED 2 arguments in format string
arg[0]
  print arg[0] % (arg[1], arg[2])

name="Chris"
age=30
printf=MyPrintf()
printf.myPrintf(("My name is %s and I am %d years old.", name, age)
will of course print...
My name is Chris and I am 42 years old.

But
printf.myPrintf(("My name is %s.", name)
of course gives
Index error: list index out of range

How can I generalize the print call in the myprintf() function to do this?

print arg[0] % (arg[1])
print arg[0] % (arg[1], arg[2])
print arg[0] % (arg[1], ..., arg[n])

-- 

---
Remove XSPAM


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


imaplib thread method anomaly

2009-02-03 Thread Mr SZ
Hi,

I was looking at the thread functionality of IMAP4rev1 servers with the 
threading extension. Here is my output with debug=8 :



  02:23.02 > GDJB3 UID THREAD references UTF-8 (SEEN)
  02:23.02 < * THREAD (3)(2)(4)(1)
  02:23.02  matched r'\* (?P[A-Z-]+)( (?P.*))?' => ('THREAD', ' 
(3)(2)(4)(1)', '(3)(2)(4)(1)')
  02:23.03 untagged_responses[THREAD] 0 += ["(3)(2)(4)(1)"]
  02:23.03 < GDJB3 OK Thread completed.
  02:23.03  matched r'(?PGDJB\d+) (?P[A-Z]+) (?P.*)' => 
('GDJB3', 'OK', 'Thread completed.')
[None]

...


  02:59.22 > CNCF3 THREAD references UTF-8 (SEEN)
  02:59.23 < * THREAD (3)(2)(4)(1)
  02:59.23  matched r'\* (?P[A-Z-]+)( (?P.*))?' => ('THREAD', ' 
(3)(2)(4)(1)', '(3)(2)(4)(1)')
  02:59.23 untagged_responses[THREAD] 0 += ["(3)(2)(4)(1)"]
  02:59.23 < CNCF3 OK Thread completed.
  02:59.23  matched r'(?PCNCF\d+) (?P[A-Z]+) (?P.*)' => 
('CNCF3', 'OK', 'Thread completed.')
  02:59.23 untagged_responses[THREAD] => ['(3)(2)(4)(1)']
['(3)(2)(4)(1)']


As you can see, the first is a UID command and the second is calling the thread 
method. Also, the server responses are the same for both. So why is one 
returning None and the other returning the correct response? I'm using 
python2.4 and I'm stuck with it as I'm using it in a zope environment.

Regards,
SZ



" life isn't heavy enough,it flies away and floats far above action"


  Make Yahoo!7 your homepage and win a trip to the Quiksilver Pro. Find out 
more
--
http://mail.python.org/mailman/listinfo/python-list


Re: Is there a better algorithm?

2009-01-02 Thread mr
As has been noted, the best is to fix the input to be regular-3-
tuples. For the fun of it, here's another variation of a solution:

tuples = [(1, 2), (3, 4, 5), (6, 7)]

def triple_or_pair(seq):
u = None
try:
k, u, v = seq
except ValueError:
k, v = seq
return k, u, v

for k, u, v in [ triple_or_pair(seq) for seq in tuples ]:
print k, u, v
--
http://mail.python.org/mailman/listinfo/python-list


Re: OT: Binary tree logarithms properties

2008-12-18 Thread Mr . SpOOn
2008/12/17 Terry Reedy :
> Nodes only have single number indexes if you arrange them linearly. Then the
> index depends on how you arrange them, whether you start the array indexes
> with 0 or 1, and whether you start the level numbers with 0 or 1.  Call the
> breadth-first sequence bf.  Then the 1-based slice for 1-first level k is
> bf[2**(k-1):2**k)].  Again, proof by induction.

Yes, I was referring to the heap numeration.
Anyway, Francesco Guerrieri answered me in a private message and
explained me the formula.

But actually I was searching for other similar properties.
--
http://mail.python.org/mailman/listinfo/python-list


OT: Binary tree logarithms properties

2008-12-17 Thread Mr . SpOOn
Hi,
I'm searching for a clear explanation of binary tree properties,
expecially the ones related to logarithms.

For example, I know that in a tree with 2n-1 nodes, we have log(n)
levels, from 0 to log(n).
So, if k is the level, the nodes on a level have indexes between 2^k
and 2^(k+1)-1.

For k=0 we have 2 and 3.
For k=1 we have 4, 5, 6, 7
and so on.

I know this after I studied some exercises on my book. Anyway there is
no explanation or demonstration of these properties.

I know this is not the better place to ask (or maybe it is?), but
maybe someone can point me to something useful.

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


Re: Free place to host python files?

2008-12-16 Thread Mr . SpOOn
2008/12/16 feba :
> Stuff like code.google, sf.net, are more oriented towards serious
> development, not just holding random apps, aren't they?
>
> Anyway, I found MediaFire, which looks like it will suffice for now.

Take a look to Dropbox (http://www.getdropbox.com/).

You can use it to directly share files with your friends or to create
a public link to your files so other people can download them.
--
http://mail.python.org/mailman/listinfo/python-list


Re: matching exactly a 4 digit number in python

2008-11-21 Thread Mr . SpOOn
2008/11/21 harijay <[EMAIL PROTECTED]>:
> Hi
> I am a few months new into python. I have used regexps before in perl
> and java but am a little confused with this problem.
>
> I want to parse a number of strings and extract only those that
> contain a 4 digit number anywhere inside a string
>
> However the regexp
> p = re.compile(r'\d{4}')
>
> Matches even sentences that have longer than 4 numbers inside
> strings ..for example it matches "I have 3324234 and more"

Try with this:

p = re.compile(r'\d{4}$')

The $ character  matches the end of the string. It should work.
--
http://mail.python.org/mailman/listinfo/python-list


Re: strange permission issue with nosetests

2008-11-20 Thread Mr . SpOOn
On Thu, Nov 20, 2008 at 13:34, Ben Finney
<[EMAIL PROTECTED]> wrote:
> Mr.SpOOn <[EMAIL PROTECTED]> writes:
>
>> Searching on google I found this: http://www.siafoo.net/article/61
>> He had the same issue and said to change permission of the file to 664.
>
> Unit test modules, which are primarily meant to be imported and have
> the tests collected and *then* run by the unit test framework, should
> be non-executable modules. I'm very glad nose enforces this.

Mmm it seems strange to me. I mean, there isn't any reference to this
on the site. How would one imagine he needs to change permission? And
it is strange that the first time I didn't need to change anything.
--
http://mail.python.org/mailman/listinfo/python-list


strange permission issue with nosetests

2008-11-20 Thread Mr . SpOOn
Hi,
I'm trying the nose testing package. I've just started reading the
tutorial and I had a problem with the first simple example.

This is the test:

def test_b():
assert 'b' == 'b'

In the same directory I gave the command nosetests and it runs the test.

Then I try with nosetests -v, but it just says this:

--
Ran 0 tests in 0.003s

OK

I thought because I didn't change anything in the file, don't know.
Tried to change, but nothing. I moved on and wrote another test,
inside a class, but nothing. It just doesn't run tests.

Searching on google I found this: http://www.siafoo.net/article/61
He had the same issue and said to change permission of the file to 664.

I tried and it worked.
Is that normal? Why does it happen?
--
http://mail.python.org/mailman/listinfo/python-list


Re: Building musical chords starting from (a lot of) rules

2008-11-19 Thread Mr . SpOOn
I think I've found a nice way to represent and build chords. At least,
at the moment it satisfy me, maybe later I'll understand how it sucks.

I'm using two separate classes: one represent a chord and is
implemented as a set of Notes; the other represents the structure
(type) of the chord and is a set of Intervals.

I can build a chord in different ways, but the general idea is that I
need a root note and a structure.

The structure isn't bound to any particular chord, because it doesn't
contain notes, but just intervals. So I can have the structure of
minor chord, of a major chord and apply them to two different notes
and build my chords.

So what is important is just the parsing of the structure. The
structure will be a string: at the moment I'm considering it space
separated, so kind of: 'min 9 no5'

I split it in a list and start from the third. I check if there's a
no3, then if there's 'min' and I put a minor third. I do the same for
the fifth. Then the first element will be the main chord structure,
because it could be a 7, a 9, a 11, a 13 and so on. I have a
dictionary with this structures, in this way:

chord_structs = {'9': ['b7', '9'], '11': ., '13': .}

So if the element is in the dictionary, I add the intervals listed,
else I just add the element. That's the case of the 7, or 6 etc. Then
I'll add the rest of the structure.

This is not complete or perfect, neither explained so well, but that's
the main idea.

Thanks for the help :D
bye
--
http://mail.python.org/mailman/listinfo/python-list


Re: Programming exercises/challenges

2008-11-19 Thread Mr . SpOOn
On Wed, Nov 19, 2008 at 3:41 PM, Philip Semanchuk <[EMAIL PROTECTED]> wrote:
> I'm not sure why you'd need to host the Python code anywhere other than your
> home computer. If you wanted to pull thousands of pages from a site like
> that, you'd need to respect their robots.txt file. Don't forget to look for
> a crawl-delay specification. Even if they don't specify one, you shouldn't
> let your bot hammer their servers at full speed -- give it a delay, let it
> run in the background, it might take you three days versus an hour to
> collect the data you need but that's not too big of deal in the service of
> good manners, is it?

Mmm, I didn't really mean the possibility to just host the code, but
to run. I mean, like server side code, so that my programs keep
running and updating, in my case, the RSS feed, without the need for
me to be online and run it.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Programming exercises/challenges

2008-11-19 Thread Mr . SpOOn
On Wed, Nov 19, 2008 at 1:50 PM, Jeremiah Dodds
<[EMAIL PROTECTED]> wrote:
> If you need to do it on the extremely cheap, you can host on your own
> machine on a port other than 80, make sure your router / firewall is
> forwarding the port to your machine, and use dyndns (http://dyndns.com) to
> give yourself a domain name. CherryPy (http://cherrypy.org) makes the python
> side of hosting a simple service or app quite painless. I use this method to
> host a little app for downloading Ubuntu packages and their dependencies as
> a tarfile on my personal machine.

Thanks, I'll try.

To turn back in topic, there is the python challenge:
http://www.pythonchallenge.com/
I started it when I was learning Python, but since the beginning it is
not as simple as they say on the site. It maybe stimulating.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Programming exercises/challenges

2008-11-19 Thread Mr . SpOOn
On Wed, Nov 19, 2008 at 1:35 PM, Jeremiah Dodds
<[EMAIL PROTECTED]> wrote:
>
> Personally, I prefer a host that gives me root on a box (or virtual
> machine). I've had a great time with slicehost (http://slicehost.com).

Yes, I knew about slicehost, but it is expensive for what I need to
do, that is just experimentin a bit.

> There are a few hosts that specialize in, or explicitly offer python
> hosting, http://wiki.python.org/moin/PythonHosting has an overview of them.

Thanks for the link, seems useful.
--
http://mail.python.org/mailman/listinfo/python-list


  1   2   >